Following are list of useful SED commands.
Replaces all occurrences of word 'Unix' with 'UNIX' in Filename.txt
sed 's/Unix/UNIX/g' Filename.txt
Print first 2 lines of filename.txt
sed -n '1,2p' filename.txt
Print all lines containing word 'Unix' in filename.txt
sed -n '/Unix/p' filename.txt
Delete all lines containing word 'Unix' in filename.txt
sed '/Unix/d' filename.txt
Delete first 2 lines of filename.txt
sed '1,2d' filename.txt
Replace all occurrences of word 'Unix' with 'UNIX' in first 10 lines of filename.txt
sed '1,10s/Unix/UNIX/g' filename.txt
Replaces all occurrences of word 'Unix' with 'UNIX' in Filename.txt
sed 's/Unix/UNIX/g' Filename.txt
Print first 2 lines of filename.txt
sed -n '1,2p' filename.txt
Print all lines containing word 'Unix' in filename.txt
sed -n '/Unix/p' filename.txt
Delete all lines containing word 'Unix' in filename.txt
sed '/Unix/d' filename.txt
Delete first 2 lines of filename.txt
sed '1,2d' filename.txt
Replace all occurrences of word 'Unix' with 'UNIX' in first 10 lines of filename.txt
sed '1,10s/Unix/UNIX/g' filename.txt
Delete empty Lines in the File
sed -i '/^$/d' filename.txt
sed -i '/^$/d' filename.txt
Products to which Article Applies
All Linux OS’s
Search Keywords: sed command find replace editing updating printing lines line file multiple replacing finding match
Article Author: Tarun Boyella
No comments:
Post a Comment