home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Run A Command Line Process On All Files In A Directory And Collect The Output Into A New File

July 2023

The Script

This was a test script for setting up a larger process. It reads all the files in a directory, passes them through a secondary process, then puts all the outputs in a single file:

Code
#!/bin/bash

OUTPATH="results file.txt"
: > "$OUTPATH"

for file in input_dir/*.txt
do
  cat "$file" \
  | tr '[:upper:]' '[:lower:]' \
  >> "$OUTPATH" 
done

Details

Example

Given these three input files:

TODO: pre
TODO: pre
TODO: pre

The script will produce:

[TODO: Result]
═══ § ═══

Footnotes And References