Getting UNIX time from the shell

vijay at bradley.UUCP vijay at bradley.UUCP
Thu Jun 15 01:28:00 AEST 1989


Ihor Kinal writes:-->
>/* ---------- "Getting UNIX time from the shell" ---------- */
>Is there any way that I can use the date command to display the
>actual UNIX time???  

   [...]

>YES, I KNOW I CAN DO THIS WITH A SIMPLE 7 LINE C PROGRAM - BUT
>CAN I DO THIS WITH JUST SHELL COMMANDS??  

   [...]

>Ihor Kinal
>cbnewsh!ijk
>{att!violin!ijk}

You do not need to write a C program to do that. A one liner
shell command will do it for you (In C Shell or Bourne Shell).
All you need is :
   
                  date | cut -f4,5 -d" "

That will give you the time. If it's a hassle having to
type that command whenever you want the time, add this to your
.profile :

           time=`date | cut -f4,5 -d" "`
           export time

or if you are using C shell, add this to your .login :

           setenv time `date | cut -f4,5 -d" "`  

Or alternatively you can create a shell file called time
with the command 

               date | cut -f4,5 -d" "

Then make that file executable and you will be set.
 
Take your pick......


=============================================================I 
  /    /                 E-mail: vijay at bradley.edu           I
 /    / *   *  ___               ...!uiucdcs!bradley!vijay   I
 /  /  /   /  /  /  /  / I===================================I
 //___/___/__/_\/__/__/  I  Exxon - Our gasoline contains no 
         /           /   I          sea water. Guaranteed!!             
        /           /    I                       
     __/         __/     I                                
===============================================================



More information about the Comp.unix.questions mailing list