Reputation: 347
Trying to prepend all files in a directory with
line1
line2
line3
with this command:
$ for i in $(ls) ; perl -pi -e 'print "line1 \nline2\nline3\n" if $. == 1' $i ; done
but I have this error:
bash: syntax error near unexpected token `perl'
perl command works for single file. Any explanation for the error?
Upvotes: 3
Views: 37
Reputation: 4778
You are missing the do
...
for i in $(ls);
do
perl -pi -e 'print "line1 \nline2\nline3\n" if $. == 1' $i ;
done
Upvotes: 4