Solved

Compress files between dates in unix

Posted on 2014-07-23
4
748 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 29

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

Technology Partners: 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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

733 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