I am using Ubuntu and I want to split my csv file into two csv files based on the value in the second column (age). The first file for patients under 60 (<60) and the second for patients over 60(>=). For example, if I have the following input:
id,age 1,65 2,63 3,5 4,55 5,78 The desired output is:
file_under:
id,age 3,5 4,55 file_over:
id,age 1,65 2,63 5,78 I have tried the following code but it removes the header (column names) how can I avoid this?
awk -F ',' '($2>=60){print}' file.csv > file_over.csv The input file is about 50k rows (lines).