Oui c'est énervant ces expansions de fichiers qui renvoient le "*" tel quel s'il ne trouve rien !
Mais c'est paramétrable, $ man bash et cherche "shopt" qui permet de changer certains comportements internes du shell, en particulier le "globbing":
nullglob: If set, bash allows patterns which match no files (see Pathname Expansion above) to expand to a null string, rather than themselves.
("shopt -s option" pour activer, "shopt -u option" pour désactiver)
Ce qui me donne par exemple:
$ ls *.gif *.jfkshkjg
ls: *.jfkshkjg: Aucun fichier ou répertoire de ce type
toto.gif
$ shopt -s nullglob
$ ls *.gif *.jfkshkjg
toto.gif
# "shopt" nullglob
Posté par daggett . En réponse au message Lister les fichiers dans un repertoire. Évalué à 3.
Oui c'est énervant ces expansions de fichiers qui renvoient le "*" tel quel s'il ne trouve rien !
Mais c'est paramétrable, $ man bash et cherche "shopt" qui permet de changer certains comportements internes du shell, en particulier le "globbing":
nullglob: If set, bash allows patterns which match no files (see Pathname Expansion above) to expand to a null string, rather than themselves.
("shopt -s option" pour activer, "shopt -u option" pour désactiver)
Ce qui me donne par exemple:
$ ls *.gif *.jfkshkjg
ls: *.jfkshkjg: Aucun fichier ou répertoire de ce type
toto.gif
$ shopt -s nullglob
$ ls *.gif *.jfkshkjg
toto.gif