Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

simple tar question

Posted on 2000-04-17
4
Medium Priority
?
294 Views
Last Modified: 2010-04-21
I am not familar with UNIX but I guess this should be an easy task for experts:
I want to find all the files whose last modified time is later than a pre-specified datetime, and 'tar' all these files. Guess I need to use 'find' command, but not really know how to do it :(

Thanks for the help!
0
Comment
Question by:wyldsj
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
kiffney earned 400 total points
ID: 2723134
touch /starting_path/comparefile -t 0401001200 && find /starting_path -name "*" -newer /starting_path comparefile | xargs tar cf newer.tar --no-recursion

This is really three commands - the first, up to the &&, uses 'touch' to create a file with a particular date and time stamp (here 4/1/2000 12:00), then the "find" command finds files newer than that date (tar has a --newer option but it's less flexible than find), and finally tar tars them up into your newer.tar archive.
0
 

Author Comment

by:wyldsj
ID: 2723648
Cool! Thanks so much!
0
 

Author Comment

by:wyldsj
ID: 2723667
Sorry maybe i am asking too much... but how can I generate the current time and format it as yymmddhhmm? It can be in perl or whatever, so long as get job done...
0
 
LVL 4

Expert Comment

by:kiffney
ID: 2723692
Well, 'touch' wants it as mmyyddhhmm, not yymmddhhmm, but to do the former you do

date +%m%y%d%k%M

and to stick that in the 'touch' command, you'd do

touch -t `date +%m%y%d%k%M`

(note the backticks around the date command - it's the key above the tab key - this tells the shell to put in the OUTPUT of that date command, or 0400171358.)

To do the yymm format, just switch the %m and the %y in the format string.  Sometimes you need perl, but I avoid it whenever possible!
0

Featured Post

Independent Software Vendors: 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

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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

916 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