With a little side of applesauce...

Monday, January 29, 2007

Using sed to delete the first match and then quit

I found this gem when I was trying to delete the first instance of a duplicate line in a group of files:


for conf in $(ls *publish*) ; do sed '0,/AllowOverride All/{//d;}' $conf ; done

I’ll extract the sed command for easier perusal:

sed ‘0,/AllowOverride All/{//d;}’ $conf

http://www.linuxtopia.org/online_books/linux_tool_guides/the_sed_faq/sedfaq4_004.html

No comments: