Search code examples
linuxglob

Why do some linux commands work with a "*" in a list of files but others do not?


why does, for instance,

ls -1 /path/to/something/data*data/file*.txt 

work fine, while something like the following returns an error:

tar -xzvf *tar.gz
tar: evsClient-v.0.0.6.tar.gz: Not found in archive
tar: evsClient-v.0.0.7.tar.gz: Not found in archive

Solution

  • The -f option to tar only expects one argument to specify the file to process. If using a glob expression as you have to tar -xzvf and there are multiple files that get expanded as a result, the files after the first one are taken to be regular arguments to tar, not an option argument to -f.

    Since you are using -x, tar is in extraction mode, and it is taking the other files to be the name of files to be extracted from the archive that it is operating on.