Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing a line

Status
Not open for further replies.

BryanY

MIS
Aug 18, 2001
54
US
I'd like to overwrite line 234 of a text file with a specific string. What is the easiest way to do this? Would i use sed?
 
One way:
awk '
NR==234{print "my specific string";next}
1
' /path/to/input > output
Another way:
echo "234s!.*!my specific string!\nwq" | ex -s /path/to/file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi:

sed supports line addressing. This changes line 234:

sed '234 s/a/bb/g' myfile


Regards,


Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top