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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -