Welcome

Apologia, decisions, & consequences

Pages

Recent Posts

Categories

Blogroll

Books

Data

Gaming

Tools

Archives

Tags

Looping through filenames in Bash

January 21st, 2024 by L'ecrivain

To loop through the subdirectories in a folder, when those subdirectories may contain spaces in the file names, use the following procedure.

OLD_IFS=$IFS && IFS=$'\n'
 for directory in $HOME/somefolder/*/; do
 echo “some code here”
 done
 IFS=$OLD_IFS

 

Posted in Computing Notes | Tagged: ,