shell - Bash List Files after a specific file -
i want run program on files in directory after specific file using bash script.
if have directory like:
filea fileb filec filed
i want run ./prog <file>
files after filec
. how write bash script this?
i have
for file in ./tests/*; ./prog $file if [ $? -eq 0 ]; echo "success: $file" else echo "**failure: $file" exit 1 fi done
but, want start @ specific file in directory. doesn't need sorted since ls
list files in specific order same each time.
i typically run script, , when fails, fix specific file, i'd want resume file, , not restart beginning.
if files sorted, can use '<'
, '>'
operators stringwise compare of 2 variables:
startfile=$1 file in ./tests/*; if ! [ "$file" '<' "$startfile" ] ; echo doing $file else echo skipping $file fi done
Comments
Post a Comment