sort
π
Sorts/randomizes input lines.
Sort lexically
echo -n 'Zack\nAdam\nCharles' | sort
Adam Charles Zack
Sort descending -r
echo -n 'Zack\nAdam\nCharles' | sort -r
Sort numerically -n
echo -n '10 Zack\n5 Adam\n1 Charles' | sort -n
1 Charles 5 Adam 10 Zack
Sort human-readable size numerics -h
echo -n '1G\n1K\n23MB' | sort -h
1K 23MB 1G
Check sorted state -c
echo -n 'Zack\nAdam\nCharles' | sort -c
sort: -:2: disorder: Adam
(Exits with a nonzero exit code that indicates unsorted input.)
Shuffle/randomize -R
echo -n 'Zack\nAdam\nCharles' | sort -R
Top comments (1)
What!!?! I never knew sort -h was a thing