Skip to main content
added 155 characters in body
Source Link
rda
  • 981
  • 1
  • 6
  • 16

Use:

grep "pattern" the_file.csv | sort -t, -nk 23 | column -ts,

or

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

with exponential notation use sort -g instead of sort -n

Explanation:

  • sort -nkk 23: sort numeric (-n) on column number 23 ( 
  • sort -kn: compare according to string numerical value
  • sort 23-g): compare according to general numerical value
  • sort -t,: sort with delimiter ,
  • column -t: make columns based on whitespaces or using delimiter (-s<delimiter>)
  • sed 's/,/ /g': substitute (s) any occurences of , with a space ' ' on all lines (g)

Use:

grep "pattern" the_file.csv | sort -t, -nk 23 | column -ts,

or

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

Explanation:

  • sort -nk 23: sort numeric (-n) on column number 23 (-k 23)
  • sort -t,: sort with delimiter ,
  • column -t: make columns based on whitespaces or using delimiter (-s<delimiter>)
  • sed 's/,/ /g': substitute (s) any occurences of , with a space ' ' on all lines (g)

Use:

grep "pattern" the_file.csv | sort -t, -nk 23 | column -ts,

or

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

with exponential notation use sort -g instead of sort -n

Explanation:

  • sort -k 23: sort on column number 23 
  • sort -n: compare according to string numerical value
  • sort -g: compare according to general numerical value
  • sort -t,: sort with delimiter ,
  • column -t: make columns based on whitespaces or using delimiter (-s<delimiter>)
  • sed 's/,/ /g': substitute (s) any occurences of , with a space ' ' on all lines (g)
added 183 characters in body
Source Link
rda
  • 981
  • 1
  • 6
  • 16

Use:

grep "pattern" the_file.csv | sort -t, -nk 23 | column -ts,

or

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

Explanation:

  • sed 's/,/ /g': substitutes any occurences of , with a space ' '
  • sort -nk 23: sort numeric (-n) on column number 23 (-k 23)
  • sort -t,: sort with delimiter ,
  • column -t: make columns based on whitespaces or using delimiter (or with -s<delimiter>)
  • sed 's/,/ /g': substitute (s) any occurences of , with a space ' ' on all lines (g)

Use:

grep "pattern" the_file.csv | sort -t, -nk 23 | column -ts,

or

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

Explanation:

  • sed 's/,/ /g': substitutes any occurences of , with a space ' '
  • sort -nk 23: sort numeric (-n) on column number 23 (-k 23)
  • column -t: make columns based on whitespaces (or with -s<delimiter>)

Use:

grep "pattern" the_file.csv | sort -t, -nk 23 | column -ts,

or

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

Explanation:

  • sort -nk 23: sort numeric (-n) on column number 23 (-k 23)
  • sort -t,: sort with delimiter ,
  • column -t: make columns based on whitespaces or using delimiter (-s<delimiter>)
  • sed 's/,/ /g': substitute (s) any occurences of , with a space ' ' on all lines (g)
added 183 characters in body
Source Link
rda
  • 981
  • 1
  • 6
  • 16

Use:

grep "pattern" the_file.csv | sort -t, -nk 23 | column -ts,

or

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

Explanation:

  • sed 's/,/ /g': substitutes any occurences of , with a space ' '
  • sort -nk 23: sort numeric (-n) on column number 23 (-k 23)
  • column -t: make columns based on whitespaces (or with -s<delimiter>)

Use:

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

Use:

grep "pattern" the_file.csv | sort -t, -nk 23 | column -ts,

or

grep "pattern" the_file.csv | sed 's/,/ /g' | sort -nk 23 | column -t

Explanation:

  • sed 's/,/ /g': substitutes any occurences of , with a space ' '
  • sort -nk 23: sort numeric (-n) on column number 23 (-k 23)
  • column -t: make columns based on whitespaces (or with -s<delimiter>)
Source Link
rda
  • 981
  • 1
  • 6
  • 16
Loading