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 |
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 |
Quote:
Yes, I still have much to learn. And, thanks! |
Quote:
Quote:
Code:
function help() { echo "Bash scripting guides: |
Quote:
|
All times are GMT -5. The time now is 02:11 PM. |