Stream Editor - Branches


In SED t command is used to create branch. t command jump if and only if the previous substitute command was successful. Let us take the same example to print the two hyphen (-).

$ sed -n ' 
h;n;H;x 
s/\n/, / 
:Loop 
/Jawaharlal/s/^/-/ 
/----/!t Loop 
p' lfc.txt 

------------------
------------------

Walden, Henry David Thoreau
- - The Discovery Of India, Jawaharlal Nehru
The Algebra of Infinite Justice, Arundhati Roy
Bookless in Baghdad, Shashi Tharoor
Adventures of Sherlock Holmes, Sir Arthur Conan Doyle






Visit :


Discussion


* You must be logged in to add comment.