Skip to content

Instantly share code, notes, and snippets.

@leopic
Created November 28, 2012 17:41
Show Gist options
  • Save leopic/4162777 to your computer and use it in GitHub Desktop.
Save leopic/4162777 to your computer and use it in GitHub Desktop.
#!/bin/bash
# add new content into the top of a file
# usage: ./script.sh 'new content to be added' myFile.txt
# @param1: content to be added
# @param2: file where the content will be added
# @author: leo picado
TEMPFILE="tmp.txt"
NEWCONTENT=$1
FILE=$2
(echo $NEWCONTENT; cat $FILE) > $TEMPFILE; mv $TEMPFILE $FILE
echo \'$NEWCONTENT\' 'was added at the top of' $FILE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment