I have a log file from where I get above CDT time 'Input', want to convert it to below format EDT time
Code:
Required output: 8/6/16 11:45 PM
#I want to get "23:45:36" in below HMS variable but it has issue
Code:
HMS=$(awk -v val=$Input '{print $2,val})
CT=`date +%Z`
if [ $CT -eq "EST" ]; then
#if EST then it is same CST time, so just formate change
F2=$(date +%r --date="$HMS" |cut -c 1-5,9-11)
F1=$(awk -F"-" -v val1=Input '{print $3"/"$2"/"$1,val1}')
echo $F1 $F2> $ET
else
#if CDT then one hour to be added to match EDT time
F1=$(awk -F"-" -v val1=Input '{print $3"/"$2"/"$1,val1}')
F2=$(date +%r --date="$HMS" "+1 hour" | cut -c 1-5,9-11)
echo $F1 $F2 >$ET
fi
The time increment and formatting not working properly, need help to get the output: 8/6/16 11:45 PM.
When we get CST time from log, the time difference to EST will be one hour. During that time increment, can we do the below?
Code:
CL_ALL=C date -d"$Input" +"%-m/%-d/%y/ %I:%M %p" "+1 hour"
First, why did you change LC_ALL in RudiC's suggestion to
Code:
CL_ALL
?
Second, why did you change:
Code:
+"%-m/%-d/%y %I:%M %p"
to:
Code:
+"%-m/%-d/%y/ %I:%M %p"
? Do you really want to print a <slash> character after the year in your output?
Third, telling us that you use bash does not tell us whether or not the date utility on your operating system supports a -d option that will behave this way. The date -d option on my system does not behave this way on the system I'm using so I can't verify this, but I would think you want something more like:
Code:
LC_ALL=C date -d"$Input +1 hour" '+%-m/%-d/%y %I:%M %p'
Fourth, the test operator for string comparison is =, not -eq (which is for numeric comparisons) and, even if it did work, your test would only work when daylight saving time is not in effect. Maybe:
Code:
if [ $CT -eq "EST" ]; then
would come closer to doing what you want if you used:
Team ,
I am new to perl. Can someone help me out to convert LDIF file to csv format using perl logic ?
LDIF file format contains values :
ID : name/Bose-IND/ORD,cu-150,ou=ends
Connection_Time: 02:12:54 EST
LDAP: yes
Link: ABC Home Page - ABC.com
Expected outcome should with column... (0 Replies)
Hi Folks,
My server time is in EDT. And i am sending automated mails from that server in which i need to display the current date time as per IST (GMT+5:30). Please advice how to display the date time as per IST.
IST time leads 9:30 mins to EDT. and i wrote something like below.
... (6 Replies)
The file contains code like the below and need to convert each one into a decimal
00 00 00 04 17 03 06 01
So the output should come as
0 0 0 4 23 3 6 1 (24 Replies)
wondering if anyone has any thoughts to convert the below thru a shell script
Convert decimal signalling point notation to ANSI point code notation
There is a site that does that conversion but i need to implement the solution in a shell script.....Thoughts....
OS: Solaris 9
... (4 Replies)
This is about how to Monitoring folder for new files using shell script
im doing a project using smsserver tools 3. i have used a perl script
to handle incoming messages. the content of each message must be
directed to a java program. this program generates the answer to reply
to the user... (2 Replies)
Helloo...
I am not much familiar with python..I found this small script in python I even do not have python on my computer...can anyone help me out to convert this into ksh or sh..
PLEASE any help I will appreciate..
here is python code..
#!/usr/bin/env python
import random # Get a... (3 Replies)
well i have this code here..and it works fine in kornshell..
#!/bin/ksh
home=c:/..../
input=$1
sed '1,3d' $input > $1.out
line=""
cat $1.out | while read a
do
line="$line $a"
done
echo $line > $1
rm $1.out
however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
I have my main script calling another script to retrive a "ls -alt" of a directory that's located in a remote location I'm sftping into.
main.sh
#!/bin/ksh
getLS.sh > output.txt
getLS.sh
#!/bin/sh
/home<..>/sftp <host@ip> <<!
cd /some/dir/Log
ls -alt
quit
!
Basically I'd like to be... (2 Replies)