I often find myself trying to do trivial text manipulations on quite large files. It seems like there ought to be a way to script this with one or other of the various Unix text mangling tools, but I can't figure out how exactly.
As a concrete example, suppose I have some source code that looks like this:
foo1 = undefined foo2 = undefined foo3 = foobar 7 foo4 = undefined
And I want to transform it to look like this:
foo1 = error "foo1" foo2 = error "foo2" foo3 = foobar 7 foo4 = error "foo4"
It looks like there ought to be some way in hell to do this transformation automatically. Obviously I can easily write a program in a real programming language. But surely there's some command-line tool that can do this. (?)
As a more complex example, how do I turn
foo=ABC bar=DEF baz=GHI foo=123 bar=456 baz=789
Magic(ABC, DEF, GHI); Magic(123, 456, 789);
More generally, which tool should I be looking at to do these sorts of transformations? Is that