Say I have a bunch of files in a Linux directory called foo.1, foo.2, and so forth, and I want to know the total size of all the files. If they were the only files in the directory, I could use “du -ab --max-depth=1” and then ignore everything but the last line. But they’re not the only files in the directory, and the other files don’t match any fixed pattern that I could use with the “-exclude” option to du.
Currently, I’m using the following hideous bit of hackery:
See? I knew there was some bit of Unix arcana I didn’t know that would help. Thanks!
(In case it’s not blindingly obvious, someone once showed me how awk could be used to extract a given column from text output and I haven’t used it for anything else since.)