this is the script I'm running

tar tf some.tar somefolder_insidetar

And output it's a list with all folders, files, and SUBDIRECTORY Files, the only thing I need it's just show the contents (folder and files) of the current directory choosed, not listing subdirectory files, or subdirectories inside subdirectories


try this:

tar tf some.tar somefolder_insidetar | grep "somefolder_insidetar/[^/]*/\?$"
  • Didn't work, Just makes a list of every the whole tar – Jesus David Gulfo Agudelo Jun 16 '11 at 20:52
  • I just edited it...please try this again – William Jun 16 '11 at 20:54
  • Well this one doesn't show anything – Jesus David Gulfo Agudelo Jun 16 '11 at 20:56
  • sorry, missed a slash :p I'll copy-n-paste this time... – William Jun 16 '11 at 20:58
  • Yes this works, Thank you very much! really appreciate your help! – Jesus David Gulfo Agudelo Jun 16 '11 at 21:00

Check this post, looks similar to what you are asking Listing the content of a tar file or a directory only down to some level

  • That's not what im searching, already tried – Jesus David Gulfo Agudelo Jun 16 '11 at 20:53

Just exclude the subdirectories with grep -v:

tar  tvzf ../xrick-021212.tgz xrick-021212 | grep -v 'xrick-021212/.*/'
  • What i want to exclude are FILES inside subdirectories, just show current folder files & directories – Jesus David Gulfo Agudelo Jun 16 '11 at 20:57
  • @Jesus: then add a dot at the end, to prevent the exclusion of subdirectories. – ninjalj Jun 16 '11 at 21:08

Your Answer

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