How can I use the test command for an arbitrary number of files, passed in using an argument with a wildcard?
For example:
test -f /var/log/apache2/access.log.* && echo "exists one or more files"
Currently, it prints
error: bash: test: too many arguments
To avoid "too many arguments error", you need
xargs. Unfortunately,test -fdoesn’t support multiple files. The following one-liner should work:By the way,
/var/log/apache2/access.log.*is called shell-globbing, not regexp. Please see Confusion with shell-globbing wildcards and Regex for more information.