Re: retrieving and comparing the timestamp of the file with current date ..

From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 04/13/05


Date: Wed, 13 Apr 2005 17:54:33 -0400

On Wed, 13 Apr 2005 at 21:25 GMT, senthilS wrote:
> Thanks Chris,
>
> Yep I tried this script and test coded, I did not get any error.

   Then you didn't run the code you posted below. Which version of ksh
   are you using? I don't have a copy of ksh88 available to test it,
   so there a (very slim) chance it will work on that. It doesn't work
   in pdksh or ksh93.

> 1)I wanted to know the why was case $7 used and also
> 2)set -- (I checked in man page for set and I could see the below
> information)
>
> sh
> set [ --aefhkntuvx [ argument ] ] ...
>
> I was using ksh so had a doubt in it.
>
> 3)Yes my code '$5 '$6' will not work properly ( but my earlier code did
> not give error, but if I would have enhanced this script this would
> have given me some problem, thanks for letting me know on this)
>
> 4) this should work I guess so.
>
> [1-9][1-9]) FILEDATE="$5 $6" ;;

   NO! See below.

> I rectified few stuff :
> ====================================
> #!/bin/ksh
>
> set -`ls -l sample.txt`

   This will still give an error.

> case "$5 $6" in
> [0-9][0-9]) FILEDATE="$5 $6" ;;

   This is NOT what you want; it works now, because there are 2 digits
   in the day of the month. In fact, this case statement does
   absolutely nothing.

   You need to pad a single digit day with an extra space.

> *) FILEDATE="$5 $6" ;;
> esac
> echo "$5 $6"
> echo $FILEDATE
>
> output :
>
> bash-2.03$ ./testtime.ksh
> Apr 3
> Apr 3

  That is not the normal output of the date command you posted
  previously. Perhaps yours is different, in which case you do not
  need the case statement at all.

> =======================================
>
> Now I am going to take the output of $FILEDATE and compare it with
> current date.
>
>
> Thanks for all your help and time on this
>

-- 
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2005, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License


Relevant Pages

  • Re: VG mirroring
    ... Host level migration of EMC frames for HPUX. ... hpux.vgclean - Per volume group clean-up script. ... Initialize the tables by running "ksh hpux.start". ... Look at inq.*.txt to see what devices come from what frame. ...
    (comp.unix.admin)
  • Re: [Long] about ksh93 (Was: Bourne Shell Programming on Windows)
    ... :>: Are you saying that David Korn is an unitiated or ignorant ksh ... :> won't be called in a script. ... :> in every shell. ... that should be teached in every shell programming book. ...
    (comp.unix.shell)
  • Re: vi horizontal split screen
    ... I'm an old ksh hacker, but bash will do fine. ... I started on the SysV R2 Bourne shell, and used csh for a better ... Several ksh improvements were designed to make it faster and more efficient at processing scripts, and one way to do that was substitute built-ins for external commands called from the script. ...
    (comp.editors)
  • Re: A couple of scripting queries
    ... This gets you /usr/local/bin/date, which is gnu date. ... ksh and bash definitely do and probably other newer bourne shells like ... in the script, ... I don't think you actually need any arrays anyways. ...
    (comp.unix.sco.misc)
  • FW: regex needed
    ... Still cant get to you chris ... you must refer to the latest post to see the working script. ... |> |I have now looped the route list, and it is saved in the hash. ...
    (perl.beginners)

Quantcast