Replace value in files

Hello All,

Please if I could get some help on the following, I have data files (due to 3rd party mistake) within each data file on line/row 3 column/field 3 - there is value '1' that need to be changed to '0'.

For example:

HEAD, TYPE OF FILE
NAME,ADDRESS
M,TYPE, 1

Now initially only two data files had the problem, so I was manually changing the 1 to 0 (as the 1 shown above) - but now I've found over 1000 files that actually have the problem (and apparently need to be changed to 0 in the next two hours). I trying to write a Unix script that does all files in one go by using AWK and SED command, or any, But I'm getting no way, any suggestion (all are welcome) .....

Try this:

awk -F, 'NR==3{$3=0}{print}' OFS="," file > newfile

thanx... I get awk error when trying something like that, what I was originally try was to highlight the row through grep then edit it:

for example

for i in `ls *`; do grep M,TYPE, 1 $i ....

then to a replace through the awk command ....

What kind of errors? Have you resolve the problem ?

I've been getting syntax errors... but I've looked at this from different approaches (also taking in account your suggestion) and I've come up with this:

---

for x in `find . -size -9000` ;do sed 's/TYPE,1/TYPE,0/' <$x> $x.new;
rm $x;
mv "$x.new" /usr/local/data/backdata"$x";
echo "$x" >> ./logfile
done

-------

But I haven't been able to test it 'cause to add to my great day the server gone done, ha!!

---------- Post updated at 10:20 AM ---------- Previous update was at 06:41 AM ----------

thanx for the Franklin52....I have it working, it was jerkin me about on the rename, but with a suggestion I moved it to another directory first.

---------- Post updated at 10:20 AM ---------- Previous update was at 10:20 AM ----------

thanx for the Franklin52....I have it working, it was jerkin me about on the rename, but with a suggestion I moved it to another directory first.