?
Solved

Compress files between dates in unix

Posted on 2014-07-23
4
Medium Priority
?
824 Views
Last Modified: 2014-07-24
How do i compress certain files in my unix folder, between two given dates with certain name?

example.

i need to compress all the files with the name file1_*.txt and date between JUN_11 and JUL_20
 all compressed into one single file, is this possible? thanks.
0
Comment
Question by:celtician
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40215956
What dates? modification time? access time? inode change time?
And what kind of compression?
0
 

Author Comment

by:celtician
ID: 40215981
gzip type of compression

dates: from july-8, to july 20
access time, any time, that parameter doesn't matter, its only creation time. same applies for modification or inode change time.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 40216021
Are the dates fixed?

If so, then

gzip file1_JUN1[1-9].txt
gzip file1_JUN20.txt
0
 
LVL 30

Accepted Solution

by:
serialband earned 2000 total points
ID: 40217698
@Tintin,

Won't that just create multiple files that are gzipped?  If you want a single file, you'll need to do some more.

You need to create 2 files with the date and time of the period you're looking for.
From your original question.
touch -t 201406110000 start_date
touch -t 201407210000 stop_date


In your follow up comment, you set your date to July-8 - July 20
touch -t 201407080000 start_date
touch -t 201407200000 stop_date


Then you can find the files between those dates and then create a tar gzip of the files
find PATH_TO_FILES -newer start_date ! -newer stop_date -exec tar -czf archive_files.tgz {} \;
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

764 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