I want to run my program on all the files in a directory after a specific file using a bash script.
If I have a directory like:
fileA
fileB
fileC
fileD
I want to run ./prog <file> for all files after fileC. How would I write a bash script to do this?
I currently have
for FILE in ./tests/*; do
./prog $FILE
if [ $? -eq 0 ]; then
echo "success: $FILE"
else
echo "**FAILURE: $FILE"
exit 1
fi
done
But, I want to start at a specific file in that directory. It doesn’t necessarily need to be sorted since ls list files in a specific order which is the same each time.
I typically just run my script, and when it fails, I fix it for that specific file, but then I’d want to resume from that file, and not restart from the beginning.
If the files are sorted, then you can use
'<'and'>'operators to do a stringwise compare of two variables: