Lesser-Known Options of Well-Known Unix/Linux Commands
levelup.gitconnected.com
levelup.gitconnected.com
For example on the df command there is a "-P --portability" option to have the output format changed to be POSIX compatible which isn't very helpful by itself. But if you look at what command options does with "info df" then it paints a more complete picture. I use that command option for bash scripting since it forces all the output to be on a single line and makes some things easier.
‘-P’ ‘--portability’ Use the POSIX output format. This is like the default format except for the following:
1. The information about each file system is always printed on
exactly one line; a mount device is never put on a line by
itself. This means that if the mount device name is more than
20 characters long (e.g., for some network mounts), the
columns are misaligned.
2. The labels in the header output line are changed to conform to
POSIX.
3. The default block size and output format are unaffected by the
‘DF_BLOCK_SIZE’, ‘BLOCK_SIZE’ and ‘BLOCKSIZE’ environment
variables. However, the default block size is still affected
by ‘POSIXLY_CORRECT’: it is 512 if ‘POSIXLY_CORRECT’ is set,
1024 otherwise. *Note Block size::.
Another favorite which I don't see getting used a lot(and isn't available on older systems) is "du --apparent-size" which calculates the disk usage with any sparse files fully expanded. Which is a niche use case but does come in handy to know.