user788171
user788171

Reputation: 17553

bash redirection inside file loop

I want to run a command like this:

while read p; grep name_ $p.config | awk -F'=' '{ print $2 }' | tr p1328 p1512 > $p.1512.config ; done < allbkgds.txt

However, this fails with the following error:

-bash: syntax error near unexpected token `done'

I can't quite understand what is going wrong because the inner command works fine:

grep name_ $p.config | awk -F'=' '{ print $2 }' | tr p1328 p1512 > $p.1512.config

I basically want to take some strings from the first config file and dump it into a second config file within the bash file loop.

Upvotes: 0

Views: 121

Answers (1)

Brian Campbell
Brian Campbell

Reputation: 332776

You're missing the do after the while clause

Upvotes: 2

Related Questions