Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash , append line at the end of each file

Tags:

bash

I have files in a dir. I need to append a new line and the file name at the end of each file.

like image 736
johnlemon Avatar asked Nov 04 '10 21:11

johnlemon


1 Answers

This should do:

for f in *; do echo >> $f; echo $f >> $f; done
  • First echo a new-line, then echo the filename.

  • The >> says "append at the end of the file".

like image 142
aioobe Avatar answered Oct 07 '22 01:10

aioobe