TunerML
asked on
Convert Batch Script to Bash
Hello Experts,
I would like to get this batch code converted to bash,
for /f "tokens=1,2" %i in ('ucommand -list ^| find /i "_ud"') do @command -f %j -user %i -delete
Thanks,
I would like to get this batch code converted to bash,
for /f "tokens=1,2" %i in ('ucommand -list ^| find /i "_ud"') do @command -f %j -user %i -delete
Thanks,
ASKER
Any possible way for it to be a one-liner? or would I need to put this in a. sh file and set chmod +x?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tried all of the above scripts and encountered errors even with some tweaking though my scripting knowledge in Unix is severely limited.
Okay so a sample output of the ./command -list would be:
"Update information...
Users:
user1 ???_???_UD year.mmdd
user2 ???_???_UD year.mmdd
user3 ???_???_UD year.mmdd
user4 ???_???_UD year.mmdd
user5 ???_???_UD year.mmdd
user6 ???_???_UD year.mmdd
user7 ???_???_UD year.mmdd
Devices:
device1 ???_???_UD year.mmdd
device2 ???_???_UD year.mmdd
..."
What I'm trying to achieve is a script that allows me to run this command for each user;
./command -f ???_???_UD -user user1 -delete
./command -f ???_???_UD -user user2 -delete
./command -f ???_???_UD -user user3 -delete
and so fourth.
Okay so a sample output of the ./command -list would be:
"Update information...
Users:
user1 ???_???_UD year.mmdd
user2 ???_???_UD year.mmdd
user3 ???_???_UD year.mmdd
user4 ???_???_UD year.mmdd
user5 ???_???_UD year.mmdd
user6 ???_???_UD year.mmdd
user7 ???_???_UD year.mmdd
Devices:
device1 ???_???_UD year.mmdd
device2 ???_???_UD year.mmdd
..."
What I'm trying to achieve is a script that allows me to run this command for each user;
./command -f ???_???_UD -user user1 -delete
./command -f ???_???_UD -user user2 -delete
./command -f ???_???_UD -user user3 -delete
and so fourth.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wouldn't have thought to remove the echo or quotes, Thanks guys.
Open in new window