cBrandon Community

General Category => Linux Fixes => Topic started by: branx86 on September 28, 2015, 10:09:04 AM

Title: SED Tutorial
Post by: branx86 on September 28, 2015, 10:09:04 AM
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'