[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: process redirection: syntax error after while loop
From: |
Bob Proulx |
Subject: |
Re: process redirection: syntax error after while loop |
Date: |
Sat, 24 Jun 2006 20:41:03 -0600 |
User-agent: |
Mutt/1.5.9i |
Chet Ramey wrote:
> Marvin Greenberg wrote:
> > while read f; do echo $f; done <~/.bash_history
> >
> > But, this fails:
> > while read f; do echo $f; done <(cat ~/.bash_history)
> > bash: syntax error near unexpected token `<(cat ~/.bash_history)
>
> That's not a redirection; it's process substitution. Process substitution
> is a shell expansion that results in a filename. Once you realize this,
> you should understand why it fails and how you can make it work.
I can't help but to post something a little more explicit. Sorry.
echo <(cat ~/.bash_history)
/proc/self/fd/63
Therefore you are saying effectively this:
while read f; do echo $f; done $FILENAME
That obviously won't work. You need a redirection operator there.
while read f; do echo $f; done < $FILENAME
Seeing that you can see that this is the right syntax.
while read f; do echo $f; done < <(cat ~/.bash_history)
Bob