Skip to content

Instantly share code, notes, and snippets.

@bennylope
Created April 6, 2015 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennylope/fad68f49bd4277ee1c69 to your computer and use it in GitHub Desktop.
Save bennylope/fad68f49bd4277ee1c69 to your computer and use it in GitHub Desktop.
Insertion shell script for prepending text to a file
#!/usr/bin/env sh
#
# Prepend the text from file in argument $1 to file in argument $2
#
#
# Usage, inserting license front matter into all Python files in a directory,
# including subdirectories:
#
# find . -name "*.py" -print0 | xargs -0 -n 1 ./prepend.sh frontmatter.txt
FRONTMATTER=$(cat $1)
CODEFILE=$(cat $2)
echo "$FRONTMATTER\n\n$CODEFILE" > $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment