The problem is that *
is a wildcard character that is expanded by the shell, but you are bypassing the shell and calling tar
directly. The tar
command is looking for one file which is named literally *.ext
and it does not exist.
Your options are:
- Expand the list of files in your own code and pass that list to
tar
. - Call the shell from your code by calling something like
/bin/sh -c tar ...
With option 2 there may be security implications -- if the shell sees something it thinks is a command, it will run it. Option 1 is therefore safer, but it's up to you which makes more sense.