Created
May 8, 2014 11:20
-
-
Save Hinidu/556ebec2c80917ae96c5 to your computer and use it in GitHub Desktop.
This file contains 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/sh | |
function process_file() { | |
[ -z "$FILE" -o -z "$RANGES" ] && return 0 | |
echo -e $RANGES | sed 's/-/,/' | sort -nr | while read RANGE | |
do | |
sed -i $RANGE"d" $FILE | |
done | |
FILE="" | |
RANGES="" | |
} | |
FILE="" | |
while read LINE | |
do | |
if echo $LINE | grep -q "should remove" | |
then | |
process_file | |
FILE=`echo $LINE | sed 's/ should remove.*//'` | |
echo $FILE | |
fi | |
if echo $LINE | grep -q "^- .*" | |
then | |
echo $LINE | |
RANGE=`echo $LINE | sed 's/^.* lines //'` | |
[ -n "$RANGES" ] && RANGES="$RANGES\n" | |
RANGES="$RANGES$RANGE" | |
fi | |
done | |
process_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment