Results 1 to 2 of 2

Thread: Shell Script Formatting

  1. #1
    Join Date
    Jul 2009
    Posts
    1

    Shell Script Formatting

    Hi friends,

    I have a script whose output is of the form:

    Time1 Time2 Port
    1070106419.581992 1070106422.034111 123

    1st 2 are unix time formats. I need to is print the the first 2 times in human readable format nd print the port also.I did tried out awk:

    awk '{print "cmd "$0""}' | csh , here cmd is my command ,but this is working for 1 column only.
    Can someone plz help by telling how can we apply different commands individually to colums

  2. #2
    Join Date
    Nov 2008
    Posts
    1,221

    Re: Shell Script Formatting

    A Unix time is basically counted from January 1, 1970. It is neither a linear representation of time nor a true representation of UTC (Coordinated Universal Time). There are two ways to convert a unix time to human readable format. First is using the below bash script:

    Code:
        !#/bin/bash
        EPOCH=1000000000
        DATE=$(perl -e “require ‘ctime.pl’; print &ctime($EPOCH);”)
        echo $DATE
        DATE=$(perl -e “print scalar(localtime($EPOCH))”)
        echo $DATE
        DATE=$(echo $EPOCH|awk ‘{print strftime(”%c”,$1)}’)
        echo $DATE
    The second is use an online site to convert the Unix time to normal time.

Similar Threads

  1. shell script SSH not working
    By Lilya in forum Software Development
    Replies: 9
    Last Post: 16-10-2010, 01:53 AM
  2. Creating shell script in ubuntu
    By Elizabeth Allen in forum Operating Systems
    Replies: 5
    Last Post: 24-03-2010, 01:35 PM
  3. Selecting a user in a shell script
    By Quattro in forum Operating Systems
    Replies: 5
    Last Post: 25-12-2009, 02:11 PM
  4. Shell script with sed
    By Ameeryan in forum Software Development
    Replies: 5
    Last Post: 23-12-2009, 02:29 PM
  5. Unix Shell Script
    By BlackSunReyes in forum Software Development
    Replies: 3
    Last Post: 12-08-2008, 01:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,547,887.29460 seconds with 16 queries