Skip to main content
added 230 characters in body
Source Link
kuspia
  • 344
  • 1
  • 6

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 protected]
Shae,Scotti,Male,[email protected]
Shae,Bonham,Female,[email protected]
Shay,Ert,Female,[email protected]
Simeon,Dearle,Male,[email protected]

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.

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 protected]
Shae,Scotti,Male,[email protected]
Shae,Bonham,Female,[email protected]
Shay,Ert,Female,[email protected]
Simeon,Dearle,Male,[email protected]

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.

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 protected]
Shae,Scotti,Male,[email protected]
Shae,Bonham,Female,[email protected]
Shay,Ert,Female,[email protected]
Simeon,Dearle,Male,[email protected]

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.

deleted 44 characters in body
Source Link
kuspia
  • 344
  • 1
  • 6

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,sbarhams3@examplesba3@exe.com
Shae,Scotti,Male,mscotti5@examplemi5@exe.com
Shae,Bonham,Female,sbonham9@examplesm9@ex.org
Shay,Ert,Female,sertp@examplesep@emple.gov
Simeon,Dearle,Male,sdearlez@examplesz@e.net

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.

I have the following CSV file as shown below with 4 columns.

Sile,Barhams,Female,sbarhams3@example.com
Shae,Scotti,Male,mscotti5@example.com
Shae,Bonham,Female,sbonham9@example.org
Shay,Ert,Female,sertp@example.gov
Simeon,Dearle,Male,sdearlez@example.net

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.

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,sba3@exe.com
Shae,Scotti,Male,mi5@exe.com
Shae,Bonham,Female,sm9@ex.org
Shay,Ert,Female,sep@emple.gov
Simeon,Dearle,Male,sz@e.net

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.

No need for real addressess here
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

I have the following CSV file as shown below with 4 coloumscolumns.

Sile,Barhams,Female,sbarhams3@accuweathersbarhams3@example.com
Shae,Scotti,Male,mscotti5@comsenzmscotti5@example.com
Shae,Bonham,Female,sbonham9@networkadvertisingsbonham9@example.org
Shay,Ert,Female,sertp@hudsertp@example.gov
Simeon,Dearle,Male,[email protected]sdearlez@example.uknet

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.

I have the following CSV file as shown below with 4 coloums.

Sile,Barhams,Female,sbarhams3@accuweather.com
Shae,Scotti,Male,mscotti5@comsenz.com
Shae,Bonham,Female,sbonham9@networkadvertising.org
Shay,Ert,Female,sertp@hud.gov
Simeon,Dearle,Male,[email protected].uk

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.

I have the following CSV file as shown below with 4 columns.

Sile,Barhams,Female,sbarhams3@example.com
Shae,Scotti,Male,mscotti5@example.com
Shae,Bonham,Female,sbonham9@example.org
Shay,Ert,Female,sertp@example.gov
Simeon,Dearle,Male,sdearlez@example.net

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.

deleted 178 characters in body
Source Link
kuspia
  • 344
  • 1
  • 6
Loading
deleted 47 characters in body
Source Link
kuspia
  • 344
  • 1
  • 6
Loading
added 61 characters in body
Source Link
kuspia
  • 344
  • 1
  • 6
Loading
added 175 characters in body
Source Link
kuspia
  • 344
  • 1
  • 6
Loading
Source Link
kuspia
  • 344
  • 1
  • 6
Loading