MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
January
Sun Mon Tue Wed Thu Fri Sat
8
       
2017
Months
Jan


Sun, Jan 08, 2017 10:50 pm

Altering the contents of a file using sed

On Unix, Linux, and OS X systems, the sed (stream editor) utility can be used to modify the contents of a file replacing one string, i.e., sequence of characters, with another. E.g., suppose the file named myfile contains the following lines:

pink blue
red Blue
orange
blue purple blue
blue

If I want to replace all occurrences of the word "blue" with "green", I could issue the following sed command at a Bash shell prompt.

$ sed -i -e 's/blue/green/g' myfile

[ More Info ]

[/os/unix/commands] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo