[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to expand sudo environment when -E doesn't



On Thu, Oct 13, 2011 at 03:58:24PM +0100, Chris Davies wrote:
> Harry Putnam <reader@newsguy.com> wrote:
> > I find sudo to be particularly ill informed at times.
> 
> >  sudo for ii in 1 2 3;do echo $ii;done 
> >  bash: syntax error near unexpected token `do'

I suspect the problem here is, perhaps not that sudo doesn't know "do",
but rather that bash terminates your command at the semi-colon.

Perhaps you should consider why you need to run a for loop as root?

Consider the following:
 for ii in 1 2 3; do sudo echo $ii; done
or
 for ii in $(sudo seq 1 3); do echo $ii; done


-- 
Darac Marjal

Attachment: signature.asc
Description: Digital signature


Reply to: