Coreutils sort

From wikinotes
Revision as of 13:42, 27 February 2022 by Will (talk | contribs) (Created page with "unix tool to sort input. = Examples = <blockquote> <syntaxhighlight lang="bash"> cat <<-EOF | sort def abc EOF # split by '/', sort by 2nd column (bat, air) cat <<-EOF | s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

unix tool to sort input.

Examples

cat <<-EOF | sort
 def
 abc
EOF

# split by '/', sort by 2nd column (bat, air)
cat <<-EOF | sort -t'/' -k2
 /foo/bat/baz.txt
 /foo/air/baz.txt
EOF

# split by '/', sort by 3rd digit of 2nd column (t, r)
cat <<-EOF | sort -t'/' -k2.3
 /foo/bat/baz.txt
 /foo/air/baz.txt
EOF