Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links


Shell Script Formatting

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 04-07-2009
Member
 
Join Date: Jul 2009
Posts: 1
Shell Script Formatting

Sponsored Links
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

Reply With Quote
  #2  
Old 04-07-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Shell Script Formatting"
Thread Thread Starter Forum Replies Last Post
shell script SSH not working Lilya Software Development 9 16-10-2010 01:53 AM
Creating shell script in ubuntu Elizabeth Allen Operating Systems 5 24-03-2010 01:35 PM
Selecting a user in a shell script Quattro Operating Systems 5 25-12-2009 01:11 PM
Shell script with sed Ameeryan Software Development 5 23-12-2009 01:29 PM
Unix Shell Script BlackSunReyes Software Development 3 12-08-2008 01:57 PM


All times are GMT +5.5. The time now is 01:17 PM.