I have a CSV file with 5 columns called "in.csv":
2,3,4,5,6
12,11,13,4,44
I want to check if for each column, column(1)+column(2) == column(3) and column(4)==column(5) holds or not, using some smart Linux command.
I have a CSV file with 5 columns called "in.csv":
2,3,4,5,6
12,11,13,4,44
I want to check if for each column, column(1)+column(2) == column(3) and column(4)==column(5) holds or not, using some smart Linux command.
Let us take this as the sample input:
$ cat in.csv
2,3,4,5,6
12,11,13,4,44
2,3,5,8,8
2,3,5,8,9
This will print all lines for which "column(1)+column(2) == column(3) and column(4)==column(5) holds":
$ awk -F, '$1+$2==$3 && $4==$5' in.csv
2,3,5,8,8
This will print all lines for which "column(1)+column(2) == column(3)" holds while ignoring columns 4 and 5:
$ awk -F, '$1+$2==$3' in.csv
2,3,5,8,8
2,3,5,8,9
This will print all lines for which "column(1)+column(2) == column(3)" is false:
$ awk -F, '$1+$2!=$3' in.csv
2,3,4,5,6
12,11,13,4,44