bash - Find files named by numbers in order but missing -
suppose files in directory named in numbers, how can find numbers missing?
for example, in current directory,
$ ls 0000.png 0002.png 0004.jpg 0005.png 0007.jpg 0001, 0003, , 0006 missing.
thanks.
you can utilize script in bash:
shopt -s extglob shopt -s nullglob arr=( +([0-9]).@(jpg|png) ) (( i=10#${arr[0]%.*}; i<=10#${arr[-1]%.*}; i++ )); printf -v f "%04d" $i; [[ ! -f "$(echo "$f".*)" ]] && echo "$f missing" done 0001 missing 0003 missing 0006 missing many @gniourf_gniourf valuable comments below prepare script.
bash
No comments:
Post a Comment