Replace string in a file using linux command

by satheeshkumar 2013-10-16 12:55:56

Replace string in a file using linux command ,

In order to replace same string or character in more than one file or all the files inside a directory, we need to use sed command in linux,

Syntax :

sed -i 's/string_to_replace/string_to_be_replaced/g' directory/filename

In following example we need to replace the string 'text' as 'all text' in all the files inside a directory..

sed -i 's/text/all text/g' directory/*.php
1467
like
0
dislike
0
mail
flag

You must LOGIN to add comments