|
| ||||||||||
| Tags: format, shell script, unix time |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Shell Script Formatting
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
| |||
| |||
| 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 |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |