News:

The Latest electronic and computer Tips that work!

Main Menu

SED Tutorial

Started by branx86, September 28, 2015, 10:09:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

branx86

Replace the word dog in file1.
Cat=string to look for
Dog=string to change cat into
Yellow dog to be the best dog.
sed s/cat/dog/ file1 #Replaces the 1st instances in a line.
sed s/cat/dog/4 #Replaces the 4th cat in a line.

To replace all the words dog in a file.
sed s/cat/dog/g <file1 >file2

Number each line left alighnment
sed=Filename |sed 'N;s/\nt/'

Double space a file
sed G
Undo double space
sed 'n;d'