User Tools

Site Tools


sed:change:change_string_on_a_specific_line_number

SED - Change - Change string on a specific line number

Replace the string on a specific line number only.

sed '3 s/unix/linux/' filename

Example

Input file

test.txt
aaaaa
bbbbb
ccccc    
ddddd
eeeee
aaaaa
bbbbb
ccccc    
ddddd
eeeee

Run:

sed '3 s/cc/linux/' file.txt

returns:

aaaaa
bbbbb
linuxccc    
ddddd
eeeee
aaaaa
bbbbb
ccccc    
ddddd
eeeee
sed/change/change_string_on_a_specific_line_number.txt · Last modified: 2021/01/09 16:03 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki