Seach Makes Easy

Labels:

Replace ORACLE with UNIX-ORACLE in a data_file

$sed 's/ORACLE/UNIX-ORACLE/' data_file

Replace two words or more words at a time

$sed -e 's/ORACLE/UNIX-ORACLE/' -e 's/DOS/UNIX/' data_file

Remove blank lines from a file

$sed '/^$/d' file_name

Delete lines between two patterns(including the pattern lines)

$ sed '/Unix-abcd/,/Dos-abcd/d' file_name

Delete lines from 10 to end of the file

$ sed 10,\$d tst

Delete lines from 10 to 300 in a file

$ sed 10,300d tst

Delete all lines expept lines in between the patterns

$sed '/ORACLE/,/UNIX/\!d' file_name

Print first line of a file

$sed q file_name

print 200th line of a file

$sed 200\!d file_name

Print last line of a file

$sed '$\!d' file_name

$sed -n '$p' file_name

list only first 20 lines of a file

$sed '20q' file_name

Print only the lines where ORACLE is present

$sed -n '/ORACLE/p' file_name

Print only the lines where ORACLE doesn't exist

$sed -n '/ORACLE/\!p' file_name

Add double spacing to a file

$ sed G file_name

How many number of lines in a file

$ sed -n '$=' file_name

Change DOS into UNIX for only the lines containing ORACLE

$sed '/ORACLE/s/DOS/UNIX/g' file_name

Change DOS into UNIX, except lines which contains ORACLE

$sed /ORACLE/\!s/DOS/UNIX/g' file_name

Reverse the order of lines

$sed -n 1\!G;h;$p' file_name

Delete all blank lines

$sed '/^$/d' file_name

Comments (0)

Followers

Blog Archive