Solved

simple tar question

Posted on 2000-04-17
4
250 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
Comment Utility
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
Comment Utility
Cool! Thanks so much!
0
 

Author Comment

by:wyldsj
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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 how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

763 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

15 Experts available now in Live!

Get 1:1 Help Now