lundi 5 janvier 2015

optimisation of bash globs


Looking for a guide to optimising regexp matches in bash.


I have a script that loops over a very long list of URLs looking for patterns. Currently it looks a little like the fragment below. Is there a guide to optimising these kinds of matches?



if [[ ${url} == */oai/request ]]
then
echo first option
elif [[ ${url} =~ .*/http://ift.tt/1IfhjAu ]]
then
echo second option
elif [[ ${url} =~ .*/[Ee][Tt][dD]-[Dd][Bb]/.* ]]
then
echo third option
elif [[ ${url} =~ .*/handle/[0-9]+/[0-9].* || ${url} =~ .*/browse.* ]]
then
echo fourth option
else
echo no-match option
fi


Aucun commentaire:

Enregistrer un commentaire