Timur Asaliev
Blog of Timur Asaliev
-
Delete recursively lines from files that match a given string
Posted on November 30th, 2009 No commentsThis is just a small snipplet to remind me of how to delete lines recursively that match a string needle
#!/bin/sh
grep -rl "needle" . |
while read filename
do
(
echo $filename
sed '/needle/d' $filename> $filename.xx
mv $filename.xx $filename
)
doneReferences used:
www.mehtanirav.com
www.cs.mcgill.ca



Recent Comments