I have a set of data formatted like this:
r 0.000 0 0 1.000 0.010
The numbers in the columns 2 and 5 vary because it is positional data (column 2) and travel-time data (column 5). However every time column 5 has a 1.000 or -1.000, it's a specific line denoting a new set of information, so I need to use awk to check for those values and edit the corresponding row.
I have tried doing various forms of
awk '{if ($5=-1.000) ($1="s" && $5=0)}' inputfile > outputfile
including only trying to change the first column from an r to an s to start with. The result should be
s 0.000 0 0 0 0.010
for every row that column 5 has a -1.000, but so far my results have just been completely blank output files. Sometimes my output replaces the entire 5th column with -1's as well, which wipes all the important data away.
EDIT: Also to clarify the data is hundreds of rows long. Here is the first 10 lines of the data to show what it consists of right now:
r 0.000 0 0 1.000 0.010
r 0.050 0 0 0.044 0.010
r 0.100 0 0 0.075 0.010
r 0.150 0 0 0.108 0.010
r 0.200 0 0 0.117 0.010
r 0.250 0 0 0.160 0.010
r 0.300 0 0 0.197 0.010
r 0.350 0 0 0.214 0.010
r 0.400 0 0 0.259 0.010
r 0.450 0 0 0.268 0.010
EDIT: Thank you for the assistance, I did eventually figure out what I was doing wrong. I didn't want to delete the question however.
Assumptions:
1.000or-1.000Sample input:
Tweaking OP's current code:
These both generate: