An example on how to use sed

25 Mar 2010 at 00:00:00 - 0 comment(s)

This post is a very short one but might be really useful. You have multiple files they all contains the same string like a parameter for config files and you would like to change it in all the files. That would take you a while if you have 100 files so here is exactly what you need in 1 simple command line using sed on Linux.

The beautiful command to use sed (it's actually the same syntax than for vim)

sed -i 's/search_for/replace_by/g' folder_*/myfile*

Another tip to extract between two line numbers with sed:

sed -n 1000,10000p file > out

You can use grep to find the line number containing a particular string:

grep -n "mystring" file

0 comments

Notify me of follow up comments