Solved

Compress files between dates in unix

Posted on 2014-07-23
4
781 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

717 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