* test the file date
@ 2003-06-10 9:50 César Soler
2003-06-10 9:49 ` Joakim Ryden
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: César Soler @ 2003-06-10 9:50 UTC (permalink / raw)
To: linux-admin
Hi,
I would like to process a pair of files if they were modified in the
previous day. I have tried with "find", but the problem is that I only
need two files:
$PATH/file
$PATH/backup/file
$PATH/export/file
if I find from "$PATH" all files, with name "file" and "-mtime -1", at
least three files appear, but I only need two of them.
Is there any shell tool to check the date? something likes "test" or
"file", that is able to check the modified time....
any clue is welcome!
Thks in advance
--
Best regards,
César mailto:csoler@euskalnet.net
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: test the file date 2003-06-10 9:50 test the file date César Soler @ 2003-06-10 9:49 ` Joakim Ryden 2003-06-10 10:10 ` Re[2]: " César Soler 2003-06-10 15:23 ` Glynn Clements 2003-06-10 21:03 ` Stephen Samuel 2 siblings, 1 reply; 7+ messages in thread From: Joakim Ryden @ 2003-06-10 9:49 UTC (permalink / raw) To: César Soler; +Cc: linux-admin On Tue, 2003-06-10 at 02:50, César Soler wrote: [...] > Is there any shell tool to check the date? something likes "test" or > "file", that is able to check the modified time.... 'stat' will give you a lot of information, including modified time. The correct options to 'ls' will as well. --Jo - To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re[2]: test the file date 2003-06-10 9:49 ` Joakim Ryden @ 2003-06-10 10:10 ` César Soler 0 siblings, 0 replies; 7+ messages in thread From: César Soler @ 2003-06-10 10:10 UTC (permalink / raw) To: Joakim Ryden; +Cc: linux-admin Hello Joakim, the problem with 'ls' is that I should get the output and view if the file was modified into the previous day. how could I call c functions from a shell? thks for your help! Tuesday, June 10, 2003, 11:49:47 AM, you wrote: JR> On Tue, 2003-06-10 at 02:50, César Soler wrote: JR> [...] >> Is there any shell tool to check the date? something likes "test" or >> "file", that is able to check the modified time.... JR> 'stat' will give you a lot of information, including modified time. The JR> correct options to 'ls' will as well. JR> --Jo -- Best regards, César mailto:csoler@euskalnet.net - To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: test the file date 2003-06-10 9:50 test the file date César Soler 2003-06-10 9:49 ` Joakim Ryden @ 2003-06-10 15:23 ` Glynn Clements 2003-06-10 21:03 ` Stephen Samuel 2 siblings, 0 replies; 7+ messages in thread From: Glynn Clements @ 2003-06-10 15:23 UTC (permalink / raw) To: César Soler; +Cc: linux-admin César Soler wrote: > I would like to process a pair of files if they were modified in the > previous day. I have tried with "find", but the problem is that I only > need two files: > > $PATH/file > $PATH/backup/file > $PATH/export/file > > if I find from "$PATH" all files, with name "file" and "-mtime -1", at > least three files appear, but I only need two of them. > > Is there any shell tool to check the date? something likes "test" or > "file", that is able to check the modified time.... "test file1 -nt file2" is true if file1 is newer than file2; conversely for "-ot". You can create a file with a specified timestamp with "touch t <date>". OTOH, you can pass the full pathname to find, e.g. find /path/to/file -mtime -1 This will output either one filename or nothing. -- Glynn Clements <glynn.clements@virgin.net> - To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: test the file date 2003-06-10 9:50 test the file date César Soler 2003-06-10 9:49 ` Joakim Ryden 2003-06-10 15:23 ` Glynn Clements @ 2003-06-10 21:03 ` Stephen Samuel 2003-06-10 21:11 ` Mr. James W. Laferriere 2 siblings, 1 reply; 7+ messages in thread From: Stephen Samuel @ 2003-06-10 21:03 UTC (permalink / raw) To: César Soler, linux-admin César Soler wrote: > Hi, > > I would like to process a pair of files if they were modified in the > previous day. I have tried with "find", but the problem is that I only > need two files: > > $PATH/file > $PATH/backup/file > $PATH/export/file > > if I find from "$PATH" all files, with name "file" and "-mtime -1", at > least three files appear, but I only need two of them. > > Is there any shell tool to check the date? something likes "test" or > "file", that is able to check the modified time.... > > any clue is welcome! > Thks in advance > it's kinda hard to figure what you mean by 'test the date'... If you're looking for something that was made 'today', then you could do something like: thismorn=`date +%y%m%d` testfile=`mktmp /tmp/today.XXXXXX` touch -t "$thismorn"0000 $testfile find /some/path -newer $testfile -print rm $testfile Note that it takes a bit more magic to properly come up with a date string for yesterday... I can think of a perl script that could do it: ----------------------- #!/usr/bin/perl die "Usage: $0 number_of_days_ago\n" $days_ago=$ARGV[0]; ( $sec, $min,$hour,$mday,$mon,$year ) = localtime(time-$days_ago*3600*24); printf "%02d%02d%02d\n", $year % 100 , $mon+1, $mday; ----------------------- (in perl, the year is years since 1900, so 2003 comes out as 103. Months are based on january being month 0, so 1 must be added to the month. I take $year mod 100 rather than blindly subtracting 100 ) note that all of these presume that you calculate the date based on your local time. If you want it based on some other time, then you should set (and export) TZ to be the appropriate timezone. eg: export TZ=GMT # Greenwich Mean Time or export TZ=EST5EDT # Eastern Standard / daylight time. sxport TZ=MST7 # Mountain Standard time (no daylight savings) If you put the perlscript in the file saysago (somewhere in your path), then the usage would be: touch `daysago 1`0000 `mktemp /tmp/ er, um, then again, you could just read the man page for find, and notice that you've got a -daystart option, which says to count file age starting at midnight, tonight rather than the current time. (time zones still apply) (Note: this solution -- while the quickest and easiest may not be portable to commercial (non-GNU) versions of the UNIX find(1) command) In other words... find /some/path -daystart -mtime -1 -print -- Stephen Samuel +1(604)876-0426 samuel@bcgreen.com http://www.bcgreen.com/~samuel/ Powerful committed communication, reaching through fear, uncertainty and doubt to touch the jewel within each person and bring it to life. - To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: test the file date 2003-06-10 21:03 ` Stephen Samuel @ 2003-06-10 21:11 ` Mr. James W. Laferriere 2003-06-10 23:03 ` Stephen Samuel 0 siblings, 1 reply; 7+ messages in thread From: Mr. James W. Laferriere @ 2003-06-10 21:11 UTC (permalink / raw) To: Stephen Samuel; +Cc: César Soler, linux-admin On Tue, 10 Jun 2003, Stephen Samuel wrote: > César Soler wrote: > > Hi, > > I would like to process a pair of files if they were modified in the > > previous day. I have tried with "find", but the problem is that I only > > need two files: > > $PATH/file > > $PATH/backup/file > > $PATH/export/file > > if I find from "$PATH" all files, with name "file" and "-mtime -1", at > > least three files appear, but I only need two of them. > > Is there any shell tool to check the date? something likes "test" or > > "file", that is able to check the modified time.... > > any clue is welcome! > > Thks in advance > it's kinda hard to figure what you mean by 'test the date'... > If you're looking for something that was made 'today', then you > could do something like: > thismorn=`date +%y%m%d` > testfile=`mktmp /tmp/today.XXXXXX` > touch -t "$thismorn"0000 $testfile > find /some/path -newer $testfile -print > rm $testfile > Note that it takes a bit more magic to properly come up with > a date string for yesterday... I can think of a perl script > that could do it: > ----------------------- > #!/usr/bin/perl > die "Usage: $0 number_of_days_ago\n" > $days_ago=$ARGV[0]; > ( $sec, $min,$hour,$mday,$mon,$year ) = localtime(time-$days_ago*3600*24); > printf "%02d%02d%02d\n", $year % 100 , $mon+1, $mday; > ----------------------- Try using gdate(date) like so . date "+%y%m%d" --date="1 days ago" > (in perl, the year is years since 1900, so 2003 comes out as 103. > Months are based on january being month 0, so 1 must be added > to the month. I take $year mod 100 rather than blindly > subtracting 100 > ) > > note that all of these presume that you calculate the date based > on your local time. If you want it based on some other time, then > you should set (and export) TZ to be the appropriate timezone. > eg: > export TZ=GMT # Greenwich Mean Time > or > export TZ=EST5EDT # Eastern Standard / daylight time. > sxport TZ=MST7 # Mountain Standard time (no daylight savings) > > If you put the perlscript in the file saysago (somewhere in your > path), then the usage would be: touch `daysago 1`0000 `mktemp /tmp/ > > > er, um, then again, you could just read the man page for find, > and notice that you've got a -daystart option, which says to > count file age starting at midnight, tonight rather than > the current time. (time zones still apply) > > (Note: this solution -- while the quickest and easiest may not be > portable to commercial (non-GNU) versions of the UNIX find(1) command) > > In other words... > > find /some/path -daystart -mtime -1 -print > > -- +------------------------------------------------------------------+ | James W. Laferriere | System Techniques | Give me VMS | | Network Engineer | P.O. Box 854 | Give me Linux | | babydr@baby-dragons.com | Coudersport PA 16915 | only on AXP | +------------------------------------------------------------------+ - To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: test the file date 2003-06-10 21:11 ` Mr. James W. Laferriere @ 2003-06-10 23:03 ` Stephen Samuel 0 siblings, 0 replies; 7+ messages in thread From: Stephen Samuel @ 2003-06-10 23:03 UTC (permalink / raw) To: Mr. James W. Laferriere; +Cc: César Soler, linux-admin Mr. James W. Laferriere wrote: > On Tue, 10 Jun 2003, Stephen Samuel wrote: >>Note that it takes a bit more magic to properly come up with >>a date string for yesterday... I can think of a perl script >>that could do it: >>----------------------- >>#!/usr/bin/perl >>die "Usage: $0 number_of_days_ago\n" >>$days_ago=$ARGV[0]; >>( $sec, $min,$hour,$mday,$mon,$year ) = localtime(time-$days_ago*3600*24); >>printf "%02d%02d%02d\n", $year % 100 , $mon+1, $mday; >>----------------------- > > Try using gdate(date) like so . > date "+%y%m%d" --date="1 days ago" Yay! they've modularized the date-pareing functions of 'at'! -- Stephen Samuel +1(604)876-0426 samuel@bcgreen.com http://www.bcgreen.com/~samuel/ Powerful committed communication, reaching through fear, uncertainty and doubt to touch the jewel within each person and bring it to life. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-06-10 23:03 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2003-06-10 9:50 test the file date César Soler 2003-06-10 9:49 ` Joakim Ryden 2003-06-10 10:10 ` Re[2]: " César Soler 2003-06-10 15:23 ` Glynn Clements 2003-06-10 21:03 ` Stephen Samuel 2003-06-10 21:11 ` Mr. James W. Laferriere 2003-06-10 23:03 ` Stephen Samuel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).