LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-24-2011, 10:54 AM   #1
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Rep: Reputation: 25
Script to find tar archives, read tar file contents, output content to an index file.


Just doing some tests, making directories into tar files:

find . -type d -links 2 -exec tar cvf {}.tar {} \;

Works fine.

I have been trying to do:

$ find . -type f -name \*.tar -execdir tar tvf {} > {}.lst \;

The result:

tar: Error is not recoverable: exiting now
tar: ./Outbox.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./Notes.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./cert8.db: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./tasks.ics: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./system.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./categories.xml: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./key3.db: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./signature-1: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./signature-0: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./calendar.ics: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./system.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./secmod.db: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: ./gvfs-metadata.tar: Cannot open: No such file or directory
 
Old 01-24-2011, 07:08 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,457
Blog Entries: 54

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Among other things (-iname, choosing between -execdir and using fixed or user-supplied full paths with loops, extension checking, getting rid of error messages) you need proper quoting as in
Code:
find /some/path/ -type f -iname \*.tar.\* 2>/dev/null|egrep -ie "\.(bz|bz2|gz|xz|z)$" 2>/dev/null|while read FILE; do tar -tf "${FILE}" > "${FILE}.ndx" 2>/dev/null; done
?
 
Old 01-25-2011, 10:46 AM   #3
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Original Poster
Rep: Reputation: 25
Quote:
Originally Posted by unSpawn View Post
Among other things (-iname, choosing between -execdir and using fixed or user-supplied full paths with loops, extension checking, getting rid of error messages) you need proper quoting as in
Code:
find /some/path/ -type f -iname \*.tar.\* 2>/dev/null|egrep -ie "\.(bz|bz2|gz|xz|z)$" 2>/dev/null|while read FILE; do tar -tf "${FILE}" > "${FILE}.ndx" 2>/dev/null; done
?
I'm mostly a hardware guy, so please go easy on me.

Yes, I still have much to learn.

And, thanks!
 
Old 01-25-2011, 11:00 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,457
Blog Entries: 54

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Quote:
Originally Posted by bluesword1969 View Post
please go easy on me.
I did, didn't you notice? :-]


Quote:
Originally Posted by bluesword1969 View Post
Yes, I still have much to learn.

And, thanks!
NP, that's what we're here for. Here's some help if you need it BTW:
Code:
function help() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html 
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html 
http://www.tldp.org/LDP/abs/html/ 
http://wooledge.org/mywiki/BashFAQ?action=show&redirect=BashFaq; }
 
Old 02-07-2011, 12:15 PM   #5
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Original Poster
Rep: Reputation: 25
Quote:
Originally Posted by unSpawn View Post
I did, didn't you notice? :-]



NP, that's what we're here for. Here's some help if you need it BTW:
Code:
function help() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html 
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html 
http://www.tldp.org/LDP/abs/html/ 
http://wooledge.org/mywiki/BashFAQ?action=show&redirect=BashFaq; }
Thank you for your help. With the nice kick start above, I was able to create some of my own scripts that did the job just nice.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 10 02-23-2008 05:40 AM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 03:15 AM
tar from contents of a text file trpn Linux - General 3 03-08-2004 01:05 AM
showing contents of a tar.Z file jpostma Linux - General 1 11-12-2003 05:14 AM


All times are GMT -5. The time now is 10:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration