Think I should use sed
, but can't get it down correctly.
I have a folder full of text files. They're all constructed the same, with a list of variables, e.g.
NAME=John
AGE=30
CODE=xyz
I need to look at all files, and modify the value of a variable, like CODE, to something.
So, file1.txt - change CODE=xyz
to CODE=123
file2.txt - change CODE=foo
to CODE=123
What I change it TO will be the same for all files.
Is sed
the best for this?
This should be able to change those values:
Running the above code will not change anything but lets you see what gets changed. To get it to chanage those values add the
-i
flag:Backups are also possible but with the kind of size, your talking about this might not be a good idea.
Information:
...
: represents just three letters or characters, so.
will be for one-type f
: we are looking for files only-i
: change the values in-place