Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 05-21-2006, 09:58 AM   #1
LQ Newbie
Registered: Aug 2003
Distribution: Debian
Posts: 12

Rep: Reputation: 0
Tar newer files since date AND TIME

I'm trying to create archives from files newer then a certain date AND TIME. The --newer option only seems to handle dates?

I've tried it with find also but find -newer works on a certain date of the file itself?

I have the dates stored in files like this 16may06 15:47:22


Last edited by ElmPie; 05-21-2006 at 04:17 PM.
Old 05-21-2006, 12:05 PM   #2
Registered: Jul 2005
Location: France
Distribution: Arch Linux
Posts: 540

Rep: Reputation: Disabled
I will try to give ideas to solve your problem.
First a way to translate your date format into one usable with the date command:
echo "16may06 15:47:22"|sed 's/\([0-3][0-9]\)\([a-z]\{3\}\)\([0-9][0-9]\) \([0-2][0-9]:[0-5][0-9]:[0-5][0-9]\)/\2 \1 \4 20\3/'
this gives:
may 16 15:47:22 2006
(I presume the year belongs to the 21st century)
you can now use this format to translate this date into a number of seconds since `00:00:00 1970-01-01 UTC' by running:
date --date="may 16 15:47:22 2006" +%s
which gives 1147787242.
Now for each file you want to know if it is newer than this date, you run:
date --reference=FILE +%s
which gives the last modification time of FILE in a number of seconds since `00:00:00 1970-01-01 UTC'
If that number is higher than 1147787242, the FILE is newer than the '16may06 15:47:22' date. And you can put it in a list of files to tar in an archive file.
You have to arrange all this in a shell-script to get what you are looking for.
I hope this will help you.

Last edited by berbae; 05-21-2006 at 12:49 PM.
Old 05-23-2006, 05:07 PM   #3
LQ Newbie
Registered: Aug 2003
Distribution: Debian
Posts: 12

Original Poster
Rep: Reputation: 0

I've figured it out.

Thanks for the help!
Old 02-23-2014, 06:32 PM   #4
Registered: Sep 2013
Posts: 31

Rep: Reputation: Disabled

I was looking for the same thing and figured it out myself:

 tar -N '2014-03-01 18:00:00' -jcvf test.tar.bz2 files
You need to put the date and time between single or double quotes and tar will interpret them correctly.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
help using --newer with tar Paxmaster Linux - Software 2 02-01-2006 10:29 AM
tar -N (newer that Date) problem johnny_cashier Linux - General 2 01-11-2006 08:08 AM
Start Date + Time Duration = End Date/Time calculator? ToBe Linux - General 3 09-26-2005 10:17 AM
Time and Date on files Azhrarn Linux - Newbie 2 09-05-2005 04:32 AM
Newer version of tar? imahdi Linux - Software 1 01-04-2005 08:26 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration