Case script to get missing sequence among files

I want to use case statement to find the range of missing sequence in my directory which it has some few ( dat & DAT ) files

my directory /home/arm/my_folder/20130428 contains :

f01_201304280000.DAT
f01_201304280001.DAT
f01_201304280003.DAT
f02_201304280000.dat
f02_201304280002.dat
f02_201304280003.dat

!#/bin/sh
main="/home/arm/my_folder"

for file in $( find $main -type f | awk -F "/" '{ print $NF}' | cut -c1-3 )
do

case $file in
f01) start=$( find $main -type f -name "$file*" | sort | cut -c13-16 | head -1)
     end=$( find $main -type f -name "$file*" | sort | cut -c13-16 | tail -1 )
     diff=$(( $end - $start ))
     miss=$file*diff*
     echo $miss

f02) start=$( find $main -type f -name "$file*" | sort | cut -c13-16 | head -1)
     end=$( find $main -type f -name "$file*" | sort | cut -c13-16 | tail -1 )
     diff=$(( $end - $start ))
     miss=$file*diff*
     echo $miss
esac

done

hope you can correct me if I were wrong ?

f01) only matches f01
f01*) matches anything starting with "f01", such as "f01_201304280000.DAT"

You have to include the wildcard * character.

Also, you need to terminate the case statements with ;; terminator.

1 Like

well thanks , I'm going to fix right now