[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need a shell script to gzip files by date.

Posted on 2006-05-25
11
Medium Priority
?
312 Views
Last Modified: 2008-02-01
I need a shell script that can compress files using gzip by modified date.
So orignally I have some 108,000 files dated from 01-01-2005 to current date. I would like the outcome to be a collection of zip files for each month and year, so I have one zip file that contains all my original files with modified dates ranging from 01-01-2005 to 01-31-2005. Then I would have another zip file for all my original files with modified dates ranging from 02-01-2005 to 02-29-2005 and so on. I would also like the oringal files deleted after sucessfull compression.

--
Jesse
0
Comment
Question by:RPIIT
  • 6
  • 3
  • 2
11 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 16765208
Do the file names have the date in them, or do you have to rely on the modification date?
0
 

Author Comment

by:RPIIT
ID: 16765279
Filenames are random numberic values, so I would have to rely on the modification date.

--
Jesse
0
 
LVL 48

Expert Comment

by:Tintin
ID: 16765504
Do you want the output to be a zip file or tar gzip file?
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 

Author Comment

by:RPIIT
ID: 16770215
A zip file that windows or winzip would be perferable but iif need by I could use a tar gzip file.

--
Jesse
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16771831
 find . -type f -printf "echo '%p' >> /tmp/T/%Ay%Am\n"|sh
  ls /tmp/T/ | awk '{printf("tar cf %s.tar `cat %s`\n",$1,$1)}'|sh

for testing simply omit the final  |sh
you may encounter problem with your shell, such as "argument too long", then you need to make smaller file list, for example by using  %Ay%Am%Ad instead of %Ay%Am
0
 

Author Comment

by:RPIIT
ID: 16773113
I will test this when I get back in the office on Tuesday.

--
Jesse
0
 

Author Comment

by:RPIIT
ID: 16792473
Ok, I hope I changed the directories to match my needs as best I understand. I am executing the following as a .sh file

find /ifs/backup/QA/Snapfish -type f -printf "echo '%p' >> /ifs/backup/QA/tmp/T/%Ay%Am\n"|sh
ls /ifs/backup/QA/tmp/T/ | awk '{printf("tar cf %s.tar `cat %s`\n",$1,$1)}'

when run I get the following result.

RPISAN-5# ./xml.sh
find: -printf: unknown option
: command not found
RPISAN-5#
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 16793804
hmm, Linux uses Gnu find, usually which has -printf option
What system are you on?
   uname -a
0
 

Author Comment

by:RPIIT
ID: 16794399
I assume it's a modified distro made by Isilon.
uname -a gives me
Isilon OneFS RPISAN-5 v3.5.2 i386
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 2000 total points
ID: 16796080
# ok, you can try with following find:
find /ifs/backup/QA/Snapfish -type f -name \*.pdf -ls | awk '{printf("%s >> /ifs/backup/QA/tmp/T/%s%s\n",$NF,$8,$9)}'|sh

but take care that the generated filenames are different, and depend on the implemented functionality of find's -ls option (in particular take care about files older than one year)
Probably you need to change $8 and $9, check before using with the final |sh
0
 

Author Comment

by:RPIIT
ID: 16994219
Unfortunatly due to staffing issues I no longer have any time to work on this project. I thank you greatly for your help and applogize for my tardy response.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question