Run shell script for every file in directory Run shell script for every file in directory unix unix

Run shell script for every file in directory


Have you tried the find command with execution ?

My sample will echo the files, but you can call a shell script with the filename as a parameter

find . -maxdepth 1 -type f -exec echo {} \;


A simple for loop in the shell:

for file in *; do sh Calculate.sh "$file"; done


find . -maxdepth 1 -type f | xargs -n 1 -I % Calculate.sh %