bash - Using sudo with for loop -
i want run simple loop command sudo, isn't working:
sudo -i -u user in /dir; echo $i; done i following error:
-bash: syntax error near unexpected token `do' probably simple thing overlooking. help?
sudo wants program (+arguments) parameter, not piece of shell script. can this, though:
sudo -i -u user sh -c 'for in /dir; echo $i; done' note single quotes. if used double quotes, shell try expand $i before sudo (or, rather, shell run it) ever sees it.
Comments
Post a Comment