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

link|improve this question
feedback

migrated from stackoverflow.com Jun 17 '11 at 2:49

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 1 down vote accepted

try this:

tar tf some.tar somefolder_insidetar | grep "somefolder_insidetar/[^/]*/\?$"
link|improve this answer
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
feedback

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

link|improve this answer
That's not what im searching, already tried – Jesus David Gulfo Agudelo Jun 16 '11 at 20:53
feedback

Just exclude the subdirectories with grep -v:

tar  tvzf ../xrick-021212.tgz xrick-021212 | grep -v 'xrick-021212/.*/'
link|improve this answer
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
feedback

Your Answer

 
or
required, but never shown