[NTLUG:Discuss] How to tell file1 is half an hour older than file2?
Paul Ingendorf
pauldy at wantek.net
Mon Apr 29 14:00:38 CDT 2002
Sorry I miss read that I expected that it would be a total shell experience
reguardless the conceptual design is still there for a pure korn shell script.
Quoting MadHat <madhat at unspecific.com>:
> stat, sed, awk, grep, echo and test are GNU tools.
> He said without gnu tools.
>
> I mean in perl, it is just a few lines (adding a few for a usage
> statement to make it pretty). Tcl isn\'t much different, or PHP (which
> can be used as a CLI script, but I wouldn\'t do it).
>
> #!/usr/bin/perl
> if ($ARGV[0] && $ARGV[1]) {
> @data1 = stat $ARGV[0];
> @data2 = stat $ARGV[1];
> if ($data1[9] > $data2[9]) {
> print \"$ARGV[0] is newer\\n\"
> } else {
> print \"$ARGV[1] is newer\\n\"
> }
> } else {
> print \"Usage: $0 <file1> <file2>
> will return the newer file based on mtime (time the file was last
> modified)\\n\\n\";
> }
>
>
> I mean if you want to use stat, you can just do
> stat -t $1 | awk -F\' \' {print\'$13\'}
> to get the date in seconds since the epoc and compare them directly,
> no
> need to convert them.
>
> There are hundreds of ways of doing this, but most use GNU tools,
> which
> he said he does not have (which seems odd to me, but...)
>
> --
> MadHat at Unspecific.com
> gpg --keyserver wwwkeys.us.pgp.net --recv-keys 9DDC3E98
> Key fingerprint = E786 7B30 7534 DCC2 94D5 91DE E922 0B21 9DDC 3E98
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
>
--
-->> mailto:pauldy at wantek.net
-->> http://www.wantek.net/
Running ....... Cos anything else would be a waste...
`:::\\\' ....... ......
::: * `::. ::\\\'
::: .:: .:.::. .:: .:: `::. :\\\'
::: :: :: :: :: :: :::.
::: .::. .:: ::. `::::. .:\\\' ::.
:::.....................::\\\' .::::..
More information about the Discuss
mailing list