Indirect File Names

When working with Linux (BSD or Unix, or even MacOS) command line programs, you often work with file names.

There’s a lot of ways to get a file’s contents processed by a command line program, all of which involve one or more file names. The base64 command is a good example:

$ base64 -d -i some_file_name
$ cat some_file_name | base64 -d
$ base64 -d < some_file_name

The -i some_file_name is the least general. That technique allows only a single file name as input, unlike the cat some_file_name technique, and does not allow another program’s output as its input, which the pipe technique allows.

I have read that Ken Thompson and/or Dennis Ritchie ultimately considered the < stdin redirection as a mistake: cat fileA fileB fileC allows input from multiple file names, not just a single file name. I have no citation for this, you can disregard this anecdote.

Of late, I’ve been using shell command output interpolation for file names.

$ vi $(git grep -l 'func AtomString')
$ vi $(echo mangler/*go)

The text between $( and ) gets executed, and its stdout interpolated. The first variant above lets you edit all files that contain the string “func AtomString” in the current git repository. The second variant lets you edit all Go source code files in the sub-directory named mangler.

Just the other day, I worked with a large number of Apache log files. I found a lot of utility in files whose contents consisted of Apache log file names. I put the file names of Apache log files that have some quality, like a particular date range, in another file. I used command output substitution like this:

$ cat july.2025.files
/home/bediger/data/access_log.164
/home/bediger/data/access_log.165
/home/bediger/data/access_log.166
/home/bediger/data/access_log.167
...
$ cat $(cat july.2025.files) | cut -f4,5 -d' ' 

That shows me timestamps from specific Apache log file lines, from July of 2025. The file named july.2025.files is an “indirect file name”. Because you can nest $() command output substitutions, you can group indirect files:

$ cat 2025.files
jan.2025.files
feb.2025.files
mar.2025.files
...
nov.2025.files
oct.2025.files
$ cat $(cat $(cat 2025.files)) | cut -f4,5 -d' ' 

Double-indirect file names are possible. If I had Apache log files from the 1990s, I could have grouped doubly indirect files by century for triply indirect files.