Skip to content

Instantly share code, notes, and snippets.

@leopic
Created November 28, 2012 17:25
Show Gist options
  • Select an option

  • Save leopic/4162690 to your computer and use it in GitHub Desktop.

Select an option

Save leopic/4162690 to your computer and use it in GitHub Desktop.
#!/bin/bash
# add new content into the top of a file
# @param1: content to be added
# @param2: file where the content will be added
TEMPFILE="tmp.txt"
NEWCONTENT=$1
FILE=$2
(echo $NEWCONTENT; cat $FILE) > $TEMPFILE; mv $TEMPFILE $FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment