Comment puis-je vérifier si le nom d'un fichier correspond à un certain motif (a-t-il "SSS", par exemple) dans la clause if
? Ma variante ne semble pas fonctionner (elle est toujours fausse).
for f in B/* ; do if [ $f = .*SSS.* ] ; then # if [ -f $f ] -and -regex ".*SSS.*"; then echo $f fi done
Vous avez besoin de parenthèses, et non '.' (Shell globbing no sed regex)
for f in B/* ; do if [[ $f = *SSS* ]] ; then echo $f fi done
Un peu de google vous donne https://stackoverflow.com/questions/2348379/use-regular-expression-in-if-condition-in-bash