Solved

simple tar question

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

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

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
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 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.

756 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