Skip to content

Instantly share code, notes, and snippets.

@luistak
Created April 2, 2020 15:43
Show Gist options
  • Save luistak/e577b0f8a8502a578c769fb5f846c7e3 to your computer and use it in GitHub Desktop.
Save luistak/e577b0f8a8502a578c769fb5f846c7e3 to your computer and use it in GitHub Desktop.
Shell Script to prepend some content into any file
#!/bin/bash
FILE=$1
DATA=$2
cat <<-EOF > $FILE
$(echo -e $DATA)
$(cat $FILE)
EOF
# Usage: ./prepend-file.sh awesome_file.txt "I'm prepending this\nMultiline string"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment