4 ms·
these are great ones! But here is mine that I recently learned: sort -h compare human readable numbers (e.g., 2K 1G)
by antimora 15y ago
these are great ones!
But here is mine that I recently learned:
sort -h
compare human readable numbers (e.g., 2K 1G)
- joelthelion 15y agoCanonical example: du -h | sort -h
- caw 15y agoSort to the same output file: sort -o foo.txt foo.txt You can't do sort foo > foo because you'll be left with a blank file.
- Karellen 15y agosponge(1) from "moreutils" Although sort(1) handles this for you as you mention, the general problem in the shell of wanting to overwrite your input file with the output file, but not being able to redirect to it for the reason you mention, is solved with sponge. Rather than: $ grep "foo" bar.txt >baz.txt; mv baz.txt bar.txt instead: $ grep "foo" bar.txt | sponge bar.txt