Replace last row of a column in bash/awk/sed

Hi,

I've got a file with 3 columns which ends like this:

...
1234  345  1400
5287  733  1400
8472  874  1400
9317  726  1400

I want to replace the last row of the last column with the value 0. So my new file will end:

...
1234  345  1400
5287  733  1400
8472  874  1400
9317  726  0

Thanks for your help

sed '$s/[0-9][0-9]*$/0/' myFile
1 Like

Vgersh99, if you remove the first number, it also works as '*' means zero or more occurrences:

sed '$s/[0-9]*$/0/' input_file 
1 Like

true, but....

...
1234 345 1400
5287 733 1400
8472 874 1400
9317 726

results in:

...
1234 345 1400
5287 733 1400
8472 874 1400
9317 726 0

which probably isn't a concern for the OP....

You are right, as the OP says:

I've got a file with 3 columns which ends like this:

Cheers.

Thanks a lot guys!