prepend

prepends the contents of one file onto another

There’s no prepend version of the >> (append) operator in bash. It requires a tiny bit of hoop jumping that this script performs.

Useful when you need to append something like a copyright notice or license to the top of every file.

Example: a quick Fish Shell loop to add a legal notice to the top of every .rakumod file in a repo.

for file in (fbn "\.rakumod")
      echo prepending to $file
      prepend legal_notice.txt $file
      git add $file
end

Usage

USAGE: prepend <prepend/me/path> <prepended/to/path>
       Prepends the contents of one file to another.
       The 1st argument is path to the file whose content you
       wish to prepend to the file in the 2nd argument.

       E.x. prepend header.txt body.txt

Metadata:

Tags:

  • text