?
Solved

simple tar question

Posted on 2000-04-17
4
Medium Priority
?
286 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
[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
  • 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.
Suggested Courses

770 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