Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!motcsd!hpda!hpcuhc!hpsemc!gph From: gph@hpsemc.HP.COM (Paul Houtz) Newsgroups: comp.unix.questions Subject: Re: Getting UNIX time from the shell Message-ID: <810067@hpsemc.HP.COM> Date: 13 Jun 89 21:07:21 GMT References: <1343@cbnewsh.ATT.COM> Organization: HP Technology Access Center, Cupertino, CA Lines: 41 I'll just give you a hack I have to put the time and date in a non-24 hour format into variables. I do this so I can use them to create dated filenames. #!/bin/ksh # This is a korn shell script. # Define a function "clock" which returns the clock time # in am or pm clock () { # Put the time part of date into $CURTIME. Could be done with # cut too... CURTIME=`date | awk '{print $4}'` # Use awk again to change 13:00 to 1:00 pm print -n $CURTIME | awk 'BEGIN {FS = ":" }{if ($1 > 12) print $1-12 ":" $2 " pm" }{if ($1 <= 12) print $1 ":" $2 " am"}' } # Okay, now you want to invoke the function to put readable time # into $time time=`clock` # Then use awk again to get the day month and year into a # separate variable called $day day=`date | awk '{print $1 " " $2 " " $3 }'` # Then print them both print -n "$day $time" # end of script This is an unnecessarily complicated way of doing what you want. I have it set up this way because I want those particular variables created. However, it should give you the idea!! Substitue "echo" for "print" everywhere except inside the awk commands, and change the function into a separate script or here document, and you will have a bourne shell script that works to. Hope this helps! Paul Houtz HP Technology Access Center 10670 N. Tantau Avenue Cupertino, Ca 95014 (408) 725-3864 hplabs!hpda!hpsemc!gph gph%hpsemc@hplabs.HP.COM