Sponsored Content
Full Discussion: Code to convert CDT to EDT
Top Forums Shell Programming and Scripting Code to convert CDT to EDT Post 302976313 by Don Cragun on Monday 27th of June 2016 10:46:43 PM
Old 06-27-2016
Quote:
Originally Posted by rozee
I am using bash

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:
Code:
if [ "$CT" = "EST" ] || [ "$CT" = "EDT" ]; then

unless you live in some parts of Indiana.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

here-doc convert 2 script convert to single script?

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)
Discussion started by: yongho
2 Replies

2. Shell Programming and Scripting

how to convert from korn shell to normal shell with this code?

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)
Discussion started by: forevercalz
21 Replies

3. Shell Programming and Scripting

python code...convert to ksh or sh

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)
Discussion started by: amon
3 Replies

4. Shell Programming and Scripting

convert perl code to shell script

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)
Discussion started by: x34
2 Replies

5. Shell Programming and Scripting

Convert decimal notation to ANSI point code notation

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)
Discussion started by: aavam
4 Replies

6. Shell Programming and Scripting

How to convert a file containing hex code to decimal using script?

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)
Discussion started by: necro98
24 Replies

7. Shell Programming and Scripting

Displaying current date time of EDT in IST time

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)
Discussion started by: Showdown
6 Replies

8. Shell Programming and Scripting

Perl Code to convert LDIF to CSV

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)
Discussion started by: Perlbaby
0 Replies
All times are GMT -4. The time now is 05:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy