Re: Parsing package filenames (was: Re: New ftp method for dselect)
Brian White:
(the above is csh code... sorry!)
I've not been following this discussion very closely, but here's a
fairly literal translation of Brian's speedup to sh:
for FILE in `sed -e 's/\(.*\)-\([^-]*\)-\([^.-]*\)\.\([^-]*\)$/\1/\2/\3/\4/'`
do (
set `echo $FILE|tr / ' '`
if [ $# = 4 ]
then
nam=$1 ver=$2 rev=$3 ext=$4
# do processing here
# ...
else
echo Error: bad file `echo $FILE|tr / -`
fi
) done
Note that I've decided to use a slash as a delimiter to allow for the
odd-ball case of a package which has a comma in its name. If / is a
bad idea, the regexp should also be changed to have an optional
directory prefix.
--
Raul
Reply to: