#!/bin/bash file="$1" echo "Removing \$assert from $file..." LOCS=`grep -n '$assert' "$file" | sed 's/:.*//g'` IFS=$'\n' for LOC in $LOCS; do START=$(($LOC-2)) END=$(($LOC+14)) echo "Deleting lines $START -> $END" sed -i -e "${START},${END}d" "$file" done