Terminal command to find and replace string in text file

by Subramanian 2014-10-08 18:30:10

Terminal command to find and replace string in text file :
 
sed -i 's/original_string/new_string/g' text_file_name.txt
Explanation:
sed = Stream EDitor
-i = in-place (i.e. save back to the original file)

The command string:
s = the substitute command
original_string = a regular expression describing the word to replace (or just the word itself)
new_string = the text to replace it with
g = global (i.e. replace all and not just the first occurrence)

 
465
like
0
dislike
0
mail
flag

You must LOGIN to add comments