home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / fj / question / unix / 674 < prev    next >
Encoding:
Text File  |  1993-01-07  |  3.5 KB  |  107 lines

  1. Path: sparky!uunet!ccut!news.u-tokyo.ac.jp!wnoc-tyo-news!icot32!tis2!tis10!ssel!ken
  2. From: ken@ssel.toshiba.co.jp (Iriuchijima Ken)
  3. Newsgroups: fj.questions.unix
  4. Subject: Re: How to compare mtime?
  5. Message-ID: <KEN.93Jan8093252@pochi.ssel.toshiba.co.jp>
  6. Date: 8 Jan 93 00:32:52 GMT
  7. References: <KEN.92Dec16131023@pochi.ssel.toshiba.co.jp>
  8.     <KANEKO.92Dec17211007@grain.rcais.tohoku.ac.jp>
  9.     <KEN.92Dec21135321@pochi.ssel.toshiba.co.jp>
  10. Sender: news@ssel.toshiba.co.jp
  11. Reply-To: ken@ssel.toshiba.co.jp
  12. Distribution: fj
  13. Organization: Systems & Software Engineering Laboratory, TOSHIBA Corporation,
  14.     JAPAN
  15. Lines: 88
  16. In-Reply-To: ken@ssel.toshiba.co.jp's message of Mon, 21 Dec 1992 13: 53:21 JST
  17. Nntp-Posting-Host: pochi
  18.  
  19. $@F~FbEg(J@$@El<G$G$9!#(J
  20.  
  21. $@F~(J> bash$@$N(Jbuiltin command$@$N(Jtest$@$K$O(J
  22. $@F~(J>           file1 -nt file2
  23. $@F~(J>                True if file1 is newer (according to  modification
  24. $@F~(J>                date) than file2.
  25. $@F~(J>           file1 -ot file2
  26. $@F~(J>                True if file1 is older than file2.
  27. $@F~(J> $@$H$$$&Hf3S1i;;;R$,$"$C$F=EJu$7$F$$$^$9!#(J
  28. $@F~(J> $@F1$8$3$H$r(Jbash$@$r(J$@;H$o$:$K(Jsh$@$G=q$/$H$7$?$i!"$I$&$7$?$i$$$$$G$7$g$&!)(J
  29.  
  30. $@$H$$$&<ALd$KBP$7!"(JNTT$@$N;0Bp$5$s!"ElKLBg$N6b;R$5$s(J$@!"02Bt!w$R$?$A$5$s$+(J
  31. $@$i$N(Jfollow$@$HEDCf(J $@Ao(J(qtanaka@cs.uec.ac.jp )$@$5$s$+$i$N(Jreply$@$rD:$-$^$7$?!#(J
  32.  
  33. $@4JC1$K$^(J$@$H$a$k$H!"(J
  34.  
  35. 1.    ls -1t$@$r;H$&(J
  36.  
  37.     if [ "`ls -1t file1 file2 | head -1`" = file1 ]; then
  38.  
  39. 2.    find ... -newer$@$r;H$&(J
  40.  
  41.     if [ -n "`find file1 -newer file2 -print`" ] ; then ....
  42.     file1$@$,(Jdirectory$@$N>l9g$O(J
  43.     if [ `find $file1 -newer $file2 -print -prune -o -prune` ]; then
  44.  
  45. 3.    $@C1BN$N(JGNU test$@$r;H$&(J
  46.  
  47.     bash-1.12$@$K$O(Jtest.c$@$,$"$j$^$9!#(Jfileutils$@$K$b$"$k$HJ9$$$?$N$G$9(J
  48.     $@$,!"(Jfileutils-3.2, binutils-1.9$@$K$O8+Ev$?$i$J$$$h$&$G(J$@$9(J...?
  49.  
  50. $@$H$$$&;00F$K$J$j$^$9!#(J($@?H6a$J$H$3$m$+$i!V(Jperl$@$O!)!W$H$b8@$o$l$^$7$?$,!"(J
  51. $@$I$&$;(Junix$@$KIU$$$F$3$J(J$@$$$b$N$r;H$&$J$i!"(JGNU test$@$NJ}$,Aa$$5$$,$7$^$9!#(J)
  52.  
  53. $@0z$C$+$+$k$H$9$l$P(J
  54.  
  55.     ls$@$G$O!"(Jfile1$@$H(Jfile2$@$NF|IU(J$@$,F1$8$H$-$O7k2L$,(Jfile$@L>$K0MB8$9$k!#(J
  56.     find$@$O$d$d5mEa$N46$,$"$k!#(J
  57.     GNU test$@$O(Jnot unix$@$G$"$k!#(J
  58.  
  59. $@$H(J$@$$$&$H$3$m$G$7$g$&$+!#8=<BE*$K$O!"(J`unix'$@$K$3$@$o$i$:$K(JGNU test$@$r;H$&(J
  60. $@$N$,7k6I4JC1$=$&$G$9$M!#(J
  61.  
  62. #    $@$G$b(J$@!"0lHV$&$J$C$?$N$O(J1.$@$N(Jls$@$r;H$&J}K!$G$9!#$3$l$O9M$($F$b$$$^(J
  63. #    $@$;$s$G$7$?!#(J
  64.  
  65.  
  66. $@3'MM$I$&$b$"$j$,$H$&$4$6$$(J$@$^$7$?!#:G8e$K(JGNU test$@$K4X$9$kEDCf$5$s$N$*JV(J
  67. $@;v$r0zMQ$7$F$*$-$^$9!#(J
  68.  
  69. $(BASH)/test.c$@$O!"(J
  70.  
  71. int
  72. #if defined (STANDALONE)
  73. main (margc, margv)
  74. #else
  75. test_command (margc, margv)
  76. #endif /* STANDALONE */
  77.      int margc;
  78.      char **margv;
  79. {
  80.  
  81. $@$J$N$G!"(J
  82.  
  83. cc -o [ -DSTANDALONE test.c
  84.  
  85. $@$9$l$P=jK>$N(J[$@$,=PMh$^$9!#(J
  86.  
  87. $@$3(J$@$l$N$*$+$2$G:#$G$O9,$;$KJk$i$7$F$$$^$9!#(J
  88.  
  89. $@IUO?(J--------------------system.h--------------------
  90. #include <ctype.h>
  91.  
  92. #define whitespace(c)    isspace((c))
  93. #define digit(c)    isdigit((c))
  94. #define digit_value(c)    ((c) - '0')    
  95.  
  96. #include <sys/stat.h>
  97.  
  98. #define S_ISREG(x) (S_IFREG & (x) ? 1 : 0)
  99. #define S_ISDIR(x) (S_IFDIR & (x) ? 1 : 0)
  100. #define S_ISCHR(x) (S_IFCHR & (x) ? 1 : 0)
  101. #define S_ISBLK(x) (S_IFBLK & (x) ? 1 : 0)
  102. $@IUO?$*$7$^$$(J----------------------------------------
  103. --
  104.     $@F~FbEg(J  $@7r(J                Tel. 044-548-5636
  105.     ken@ssel.toshiba.co.jp            FAX  044-533-3593
  106.     $@3t<02q<REl<G(J $@8&5f3+H/%;%s%?!<(J $@%7%9%F%`!&%=%U%H%&%'%"@8;:5;=Q(J$@8&5f=j(J
  107.