Solved

simple tar question

Posted on 2000-04-17
4
260 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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
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.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now