Skip to content

Instantly share code, notes, and snippets.

@marcogrcr
Created July 19, 2024 15:31
Show Gist options
  • Save marcogrcr/54c9d10c78a9c11d9820b1731ae8357a to your computer and use it in GitHub Desktop.
Save marcogrcr/54c9d10c78a9c11d9820b1731ae8357a to your computer and use it in GitHub Desktop.
A POSIX-compatible recursive iteration over each file
#!/bin/sh
folder_path='...'
file_types='*.json'
# See https://www.shellcheck.net/wiki/SC2044 for why we loop this way
find "$folder_path" ! -name "$(printf "*\n*")" -name "$file_types" | while IFS= read -r file
do
echo "Processing $file..."
# process $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment