Use redirection to stop programs printing out filenames in their output

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2024-11-21

This is a general purpose trick to stop programs from printing out filenames given to them as arguments: feed the program its data via redirection instead of via an argument file name.

e.g. wc -l oxnotes.log prints 134344444 oxnotes.log, the extra filename being annoying for feeding the line count into arithmetical subexpressions.

but wc -l < oxnotes.log just gives the number. Presumably wc never received a filename argument here, therefore cannot possibly print it.