I'm doing a project in which I have to parse a csv file (indian liver patient dataset) and I'm trying to change the position of one column. The second to last must be the last column. I'm following these approach but I don't know if It is the right one:
while IFS="," read -r col1 col2 col9 col8 col
do
echo "$col1, $col2, $col9, $col8"
done < <(cut -d "," --fields=1,2,9,8 csvfile)
Also I need to separate between "Male" and "female" (col2), and just show those values where col9 = 3. The desire output is:
Women
38,Female,3, 5.6
38,Female,3, 5.6
32,Female,3, 6
and so on
Men
72,Male,3, 7.4
60,Male,3, 6.3
33,Male,3, 5.4
and so on
How can I do that without using grep or akw?