Image

Imagemuerte wrote in Imagelinux

Simple way to edit a single line?

Everytime I think of something that "would be handy" on linux I find out it's already written and part of the core distro. So I'll ask this here.

Give a file foo.txt, is an easy way to go through it line by line looking for a line "abc123" and convert it to "def456"

I'm thinking something simple like:

searchreplace /tmp/foo.txt "abc123" "def456"

Where it would just replace all occurances in a file of itemA with itemB. Granted this is like a 4 line perl script, I want something that would be part of the OS so if I go to a new company or new business I don't have to download scottscustomperlscript.pl on every new machine I touch.

This is probably a job for AWK or SED I'm guessing? Anyone? Anyone? Bueller?