Script to list the contents of the latest archive?
Hi,
I am looking to write a script that will: Get the latest Archive from a list List the contents of the tar.gz Print the name, size, and date of modification I have: Code:
gunzip -c ~/backups/PROJECTNAME_2013-02-28-16:27:27.tar.gz | tar -tvf - r--r-- ubuntu/ubuntu 5 2013-02-19 03:15 file0 -rw-r--r-- ubuntu/ubuntu 0 2013-02-28 16:47 fil1 -rwxr-xr-x ubuntu/ubuntu 795 2013-02-19 01:51 fil2 -rwxr-xr-x ubuntu/ubuntu 643 2011-11-20 14:13 fil3 But I want to sort this by last modification date: Code:
gunzip -c ~/backups/PROJECTNAME_2013-02-28-16:27:27.tar.gz | tar -tvf - | sort -n -rw-r--r-- ubuntu/ubuntu 0 2013-02-28 16:47 fil1 -rw-r--r-- ubuntu/ubuntu 5 2013-02-19 03:15 fil0 -rwxr-xr-x ubuntu/ubuntu 643 2011-11-20 14:13 fil3 -rwxr-xr-x ubuntu/ubuntu 795 2013-02-19 01:51 fil2 Any ideas? to get order right: name, size, and date of modification |
You have to specify the field to be sorted out, using the -k option:
Code:
sort -k4n Code:
tar tvf ~/backups/PROJECTNAME_2013-02-28-16:27:27.tar.gz | sort -k4n | cut -d' ' -f6-,3,4 |
Quote:
|
All times are GMT -5. The time now is 08:39 AM. |