[svlug] Shell Programming Question
Seth David Schoen
schoen at loyalty.org
Fri Jul 21 11:10:02 PDT 2000
Sean Cheng writes:
> #separate the sub-filename, if sub-filename matches prt then
> #backup the file
> subname=`echo $file|cut -d"." -f2`
> test "$subname"="prt" && {echo $subname;echo $file}
Aside from the spaces around the equals sign, and the problem that a
filename with no dot leads to a syntactically incorect test, why not
just use shell globbing, like
for file in *.prt{,.*}
You'd want to check if the files exist, like
[ -f "$file" ]
to catch wildcard patterns that don't match anything.
--
Seth David Schoen <schoen at loyalty.org> | And do not say, I will study when I
Temp. http://www.loyalty.org/~schoen/ | have leisure; for perhaps you will
down: http://www.loyalty.org/ (CAF) | not have leisure. -- Pirke Avot 2:5
More information about the svlug
mailing list