Text Processing – Deleting Lines Containing a Specified String in Different Files

findgrepsedtext processing

Suppose there are two files in web/ named foo.php and bar.php. The 1st line of foo.php is "sdajgeSTRINGdsad" and the 10th line of bar.php is "gdfhu98324STRING". The task is to first locate these two files, then delete 1st line of foo.php and 10th line of bar.php given that the specified string is "STRING".

Best Answer

sed can do that :

sed -i.bak '/STRING/d' web/*
Related Question