SED (stream editor)

SED is a stream editor , command line version of text editor, It is a scripting based for text file editing. There are some other similar powerful programs are awk, python and perl.

Using "sed" as command in terminal

> sed   's/old/new/'   file          ####  sed invokes the editor tool,  "command" in quotations and the filename to be edited is mentioned at last

>'s/old/new/'  in this command 's' for substitute '/' is delimiter (separator)the given command will be used to replace the specified keyword in file with new keyword

>we can also replace multiple keywords to a single keyword by using pipe for multiple keyword separator    .ie  's/ashok\|arya\|arjun/A./' 

>nl  file.txt | sed 's/hi/Hi/'  > output.txt             #### nl adds the line numbers to file and  pipes to the sed command as input and the sed command output is redirected to output.txt file

> sed 's/hi/Hi/'  < file.txt > output.txt

Using "sed" as script 

>

Comments