I have the following CSV file as shown below with 4 columns, and I am taking input of filename from bash terminal.
Sile,Barhams,Female,email@example.com Shae,Scotti,Male,firstname.lastname@example.org Shae,Bonham,Female,email@example.com Shay,Ert,Female,firstname.lastname@example.org Simeon,Dearle,Male,email@example.com
Desired output is:
Shae,Male Shae,Female Shay,Female Sile,Female Simeon,Male
Now I tried following code snippets and got the result as shown :
cat $file | cut -d, -f1,3 | sort -k 1,1 -s Shae,Female Shae,Male Shay,Female Sile,Female Simeon,Male cat $file | cut -d, -f1,3 | sort -k 1,1 -s -n Sile,Female Shae,Male Shae,Female Shay,Female Simeon,Male
Can somebody explain my both snippets and how I can get desired one please, according to me for first code I am sorting according to first column and in case of tie I have specified stable sort to get the desired output but IDK what is the issue and in second code I wonder how "Sile" appears on the top.