Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

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

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

3 Answers 3

up vote 1 down vote accepted

try this:

tar tf some.tar somefolder_insidetar | grep "somefolder_insidetar/[^/]*/\?$"
share|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

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

share|improve this answer
    
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/.*/'
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.