I have a very simple problem, but for reasons it does not work properly..
I have these .txt
files in the following format
2 250 1
4 250 1
5 250 1
I wanted to subtract 1 from the numbers in the first column, yielding:
1 250 1
3 250 1
4 250 1
I am using this code in bash:
awk '{ print $1-1,$2,$3 }' file.txt > newfile.txt
I think this code is fine, however, due to the fact that these text files have their file extension changed from .csv
to .txt
, this awk line doesn't seem to work well. It yields:
1 250 1
4
Any alternatives that can work well with these text files I have?
updates: I used the pico editor to re-generate one of these files, and now the above code works perfectly, so there must be something wrong in the original text files in terms of formatting and properties…any insights?
.csv
to.txt
should make a difference;awk
is agnostic. – Sparhawk Mar 10 '16 at 00:40hexdump -c file.txt
? – Sparhawk Mar 10 '16 at 01:34