I want to write a bash script that (recursively) processes all files of a certain type.
I know that I can get the corresponding list of files using find:
to find. -name "* .ext"
I want to use this in a script:
- recatin obatin list of files with a given extension
- get the full path to the file
- pass the full path to another script
- Check the return code from the script. If there is no zero, write down the name of the file that cannot be processed.
My first attempt looks (pseudo-code) as follows:
ROOT_DIR = ~/work/projects
cd $ROOT_DIR
for f in `find . -name "*.ext"`
do
newname = `echo $f | cut -c 3
filename = "$ROOT_DIR/$newname"
retcode = ./some_other_script $filename
if $retcode ne 0
logError("Failed to process file: $filename")
done
bash script, . , , , , - , script.
Ubuntu