Skip to content

Instantly share code, notes, and snippets.

@niko
Created April 23, 2009 18:02
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 niko/100645 to your computer and use it in GitHub Desktop.
Save niko/100645 to your computer and use it in GitHub Desktop.
function greparate() {
PATTERN=$1;
FILENAME=$2;
FILENAME_WITH=`echo $FILENAME | sed "s/\.\([^\.]*\)$/.with_$PATTERN.\1/"`;
FILENAME_WITHOUT=`echo $FILENAME | sed "s/\.\([^\.]*\)$/.without_$PATTERN.\1/"`;
echo "Seprating the content of $FILENAME by $PATTERN into $FILENAME_WITH and $FILENAME_WITHOUT"
grep $PATTERN $FILENAME > $FILENAME_WITH;
grep -v $PATTERN $FILENAME > $FILENAME_WITHOUT;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment