0

tar -tf file.tar.gz let's me view inside the whole archive. How do you view a specific path without viewing the whole thing? E.g., I want to view only /path/foo/

Update:

This command almost works but it doesn't list the files inside /foo/

tar --exclude="*/*" -tf file.tar /path/foo/

  • Have you tried tar -tf file.tar.gz /path/foo/? – DavidPostill Jul 7 '18 at 8:19
  • @DavidPostill that works but is it possible to only list stuff in the first level of /path/foo/? (e.g., /path/foo/folder/ instead of /path/foo/folder/subfolder/subfolder/file.txt) – IMB Jul 7 '18 at 8:57
  • @DavidPostill Thanks. I'm almost there but I can't get to my desired results. I am doing this tar --exclude="*/*" -tf file.tar /path/foo/ (highest voted on that page) but it only shows the folder, no files are shown (as indicated by the comment in that page). Do you know how to show the files as well? The selected answer on that page (the one using awk) is not really what I'm looking for. – IMB Jul 7 '18 at 9:57
  • No idea, but please edit your question to include what code you are actually using and why it doesn't meet your needs. – DavidPostill Jul 7 '18 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.