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?
You are missing the do...
for i in $(ls);
do
perl -pi -e 'print "line1 \nline2\nline3\n" if $. == 1' $i ;
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With