Results 1 to 7 of 7
  1. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #1  
    I would like to be able to create a shell script that would list archive files and their labels in this format....

    full_file_path_and_name volume_label

    It doesn't have to be the full path and file name if just the filename that would be kewl also.

    The closest I have gotten is ...

    Code:
    ls /full/path/to/file/*.tar.gz | /bin/tar --test-label
    this yeilds...

    Code:
    /bin/tar: line 1: /full/path//to/file/file_no_1.tar.gz: Permission denied
    /bin/tar: line 2: /full/path//to/file/file_no_2.tar.gz: Permission denied
    /bin/tar: line 3: /full/path//to/file/no_label.tar.gz: Permission denied
    /bin/tar: line 4: /full/path//to/file/file_no_3.tar.gz: Permission denied
    Last edited by DrewPre; 03/21/2010 at 05:24 PM.

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  2. #2  
    Try something like this:
    Code:
    for i in `ls /full/path/to/file/*.tar.gz`; do /bin/tar --test-label $i; done
  3. #3  
    The find command has an exec flag that you can run a command on every result you have. You can search by filename no problem.

    find /full/path/to/file/ -name *.tar.gz -exec /bin/tar --test-label {} \;

    The /full/path/to/file is the root of wherever you want to search for tar.gz files.
    I have never used the --test-label flag before, but it looks like there is some info here:
    GNU tar 1.23: 9.7 Including a Label in the Archive
  4. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #4  
    Quote Originally Posted by joshewah View Post
    The find command has an exec flag that you can run a command on every result you have. You can search by filename no problem.

    find /full/path/to/file/ -name *.tar.gz -exec /bin/tar --test-label {} \;

    The /full/path/to/file is the root of wherever you want to search for tar.gz files.
    I have never used the --test-label flag before, but it looks like there is some info here:
    GNU tar 1.23: 9.7 Including a Label in the Archive

    That's actually the command I am using and it's just printing out the label names and not the filenames along with it.

    Would like to have the file names alongside the label.

    The 'for' loop just sits there and doesn't return anything.

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  5. #5  
    OK, you can just add a second exec if you want:

    find /full/path/to/file/ -name *.tar.gz -exec /bin/tar --test-label {} \; -exec ls {} \;

    There is also a -ls flag for find that will list the file.
    It will do that, then run the the exec command for each match.

    For the for loop, I usually use this method instead of the one given earlier:
    for i in $(ls /full/path/to/file/*.tar.gz)
    but it might only work in bash.
  6. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #6  
    Looks like that may work, mate! Thanks much!!

    It's not side by side... It's more one after the other....e.g....

    vol_label_1
    /full/path/to/file/file_1.tar.gz
    vol_label_2
    /full/path/to/file/file_2.tar.gz
    vol_label_3
    /full/path/to/file/file_3.tar.gz
    vol_label_4
    /full/path/to/file/file_4.tar.gz
    vol_label_5
    /full/path/to/file/file_5.tar.gz

    ....

    vol_label_n
    /full/path/to/file/file_n.tar.gz

    That sufficient enough to work. I think. Thanks again.

    Palm Pre Backup Utility...done!
    Locate Pre....done!
  7. DrewPre's Avatar
    Posts
    818 Posts
    Global Posts
    829 Global Posts
       #7  
    Yes, that worked very nicely!!!!

    Wow, you saved me from having to make a more complex service!!

    Heh! I believe I am done! .... AND THIS TIME FOR REAL LOL....Code Cleanup ...as it were.... is all that is left.

    I can have my life back! HA!

    Palm Pre Backup Utility...done!
    Locate Pre....done!

Posting Permissions