I'm writing a program that takes in 'Radiosonde Weather Balloon' data and writes it to a new file.
The data is structured in a way that there are 7 columns. I'm only interested in rows that have 4, 7, or 9 in the first column, and also have numbers less than or equal to 9000 in both columns 4 and 6.
This is what I have written:
awk '{if ($1 == 4 || $1 == 7 || $1 == 9 && $4 <= 9000 && $6 <= 9000) print $2/10,$3/1e3,$4/10,$5/10,$6,$7/10}' $1 > sonde_tv
My output file only has the lines that have 4, 7, or 9 in the first position, but it will still have data over 9000 in columns 4 and 6.
What am I doing wrong?
if ($1 == 4 || $1 == 7 || $1 == 9 || ($4 <= 9000 && $6 <= 9000)). If you truly intend 'rows 4 and 6', then you need to compare variableNRwith those numbers, and…well, it is ambiguous what it means when you say "those that have numbers less than 9000 in rows 4 and 6'. Fortunately, you probably don't mean this. Whatever you intend, the answer is to make sure you put enough brackets into the condition to ensure that it is unambiguous to both the humans and the computers that have to read it.