I have file with below content
FG1620000|20000
FG1623000|23000
FG1625000|25000
FG1643894|43894
FG1643895|43895
FG1643896|43896
FG1643897|43897
FG1643898|43898
My aim is to split the above file into two files based on the value in the second field.
If the value in second field is <=30000, the field one should written into a separate file "high.txt"
"high.txt"
FG1643894|43894
FG1643895|43895
FG1643896|43896
FG1643897|43897
FG1643898|43898
"low.txt"
FG1620000|20000
FG1623000|23000
FG1625000|25000
My code is
cat file| awk -F'|' '{ if ($1 <= "20000") {print $1 >> "high.txt"} else {print $1 >> "low.txt"} }'
but the entire content of the file gets printed to "low.txt"
Where am I going wrong?