List files

I am trying to use pattern matching in case under shell script but I am getting some problem.

Want files starting from s-z and ending with pbrt.

I want to perform some action having filename as : [s-z]*.pbrt

but when I am writing

case "$file" in
[s-z]*.pbrt) echo "Successful"
;;
*) ;;
esac

its not working. Can somebody help me out?

#ls | egrep -c "[s-z]\.pbrt+$"
#1
#v=`ls | egrep -c "[s-z]\.pbrt+$"`

with the out put you can add a condition to execute next .

if [ $v ge 1
then
.
.
else
...
...
fi

if [ ! -z "`ls | egrep "[s-z]\.pbrt+$"`" ] ; then
   echo "Found"
else
   echo "Not found"
fi

You were close:

% touch sa.pbrt aa.prpb vb.pbrt
% ls                
aa.prpb  sa.pbrt  vb.pbrt
% set -- [s-z]*.pbrt               
% [ -f "$1" ] && echo OK || echo KO
OK
% rm sa.pbrt vb.pbrt 
% [ -f "$1" ] && echo OK || echo KO
KO

I like that OK KO thing :slight_smile:

[ "$(echo "[s-z]*.pbrt")" != "[s-z]*.pbrt" ] && echo OK || echo KO