Search code examples
bashconcatenation

Shell script to append text to each file?


I have a folder full of text files. I need to append the same block of text to each of them (and of course overwrite the original file).

I was wondering what the correct Bash shell syntax would be for this. Would I use cat?

I have done a few batch scripts but I'm not a Bash expert. Any suggestions appreciated.


Solution

  • Use append redirection.

    for f in *.txt
    do
      cat footer >> "$f"
    done