I have a filename fofo.l stored in variable FI. I want to check if there “.l” in file name. If so, command1 is executed. If not, command2 is executed.
I used set -x
and tried:
if test $FI == *.l*; then echo done; else echo fail; fi
that is output:
+ test fofo.l == esc.txt execve.c fofo. fofo.l foo1.cpp foo2.c foo.c foo.gz foo.l fool.sl foo.save foo.sl foo.xz goo.xz goo.xz.orig mprint.c myecho2.c myecho.c nano.10558.save p1.c pm.c pm.o term.cpp zipT.gz
bash: test: too many arguments
+ echo fail
fail
As far as I know, bash just replace * by any amount of characters. But there are plenty of appropriate files. So how can I solve this problem? Should I reduce an amount of arguments? Should I go the other way?
New contributor
Evgeny is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.