Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
replacing fields in delimited file
Name: u9717410 Date: September 3, 2004 at 07:09:35 Pacific OS: hp ux 11 CPU/Ram: unknown
Comment:
I am trying to tag a number onto the front of a unique field in a datafile. At the moment i can do this to the second field in a file because it is always preceeded by a D and a pipe delimeter ie 'D|'. There fore i am using this where pIncrese is the number to be put on the front
sed "s/^D|\(.*\)|/D|${pIncrease}\1|/" \
I now want to be able to do the same thing but to the third field in another file, i tried this unsucessfully
sed "s/^D|\(.*\)|\(.*\)|/D|\(.*\)| \ ${pIncrease}\1|/"
the third fourth fifth etc fields can only be identified by the number of '|' chracters preceeding them.
Summary: Replace /MM_VERSION_STR/ in the above by: $1 == "#define" && $2 == "MM_VERSION_STR" in case MM_VERSION_STR appears elsewhere in the same file. ...
Summary: How can i edit a field in a file (saving the changes in the file) using awk. I can find the line that i want to edit by looking up field 1, but on that line, i don't know how to edit field 2 and save ...
Summary: Hi, how do we change a variable's value in a file? e.g. $ cat <file1> AGE=1 bla bla........... i need to change the value of variable "AGE" to a newvalue(let's say "0") Thanks, Amit ...