Home > linux > edit a string in multiple files: sed -ic

edit a string in multiple files: sed -ic

ottobre 19, 2012

Sed is a great tool used to edit one line if needed for multiple files without open it.
Usually to do this, you just need to:

1. Looking for the right regular expression:

grep -re “user” /my/dir

2. Inject the update string

sed -ic ‘s/user/newuser/g’ <filename>

3. Enjoy!


WARNING : the option “-c” is needed to preservate the owner of the file, if not set the file change permission with the actual owner.

Categorie:linux Tag:, , , ,
  1. gennaio 10, 2013 alle 10:56 am

    Hi to every single one, it’s actually a good for me to pay a visit this web page, it consists of useful Information.

  1. No trackbacks yet.
I commenti sono chiusi.