Created
November 28, 2012 17:41
-
-
Save leopic/4162777 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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