I would like to know if it is possible to extract a specific file inside tar file using find command.


  • Normal situation: find filaname called "file1" and extract

    tar xvf tarfilename file1 
  • My Situation:

    find . -iname "*tar*" -exec tar -xvf *file1* {} \;

    I don't know if possible to do.


My internal prod system is not allowed to run tar command.

I know that the best practice is running tar directly, but the hope dies last

Thanks in advance.


1 Answer 1


If you can't run tar directly from the shell, but can run it from a different command, then you can do:

env tar xvf file.tar file1
find . -prune -exec tar xvf file.tar file1 ';'
perl -e 'exec @ARGV' tar xvf file.tar file1

However, that still runs tar, so you would likely still be infringing at least the spirit of the law that forbids you from running tar.

Instead of tar, you could also run pax instead (that's the POSIX command for dealing with archives).

pax -r < file.tar file1
  • I'm able to use env tar to solve my problem Thank you so much. Commented Nov 6, 2020 at 3:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .