Seelct case based on current time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Seelct case based on current time
# 1  
Old 07-19-2015
Seelct case based on current time

HI Guys im tring to write a bash sccript which will give me the time of the next us from my local stop

i have a list of times as below

Quote:
0735
0805
0835
0905
0935
0950
1020
1050
1120
1150
1220
1250
1320
1350
1420
1450
1520
1550
1620
1650
1650
1720
1800
1840
1922
1942
2002
2022
2102
but have no dea how to do thia using a select case of if then statment can any one give me a heads up ?

any help would be appreciated

Pete
# 2  
Old 07-19-2015
Using case statements

Give it a try and let us know what you've come up with Smilie
# 3  
Old 07-19-2015
Trying heavily to infer your request from the fragments of orthography that you posted, and presuming a grep with the -A option, I came up with
Code:
date +"%H%MX" | sort - file | grep -A1 X | tail -1
1922

This User Gave Thanks to RudiC For This Post:
# 4  
Old 07-19-2015
Quote:
Originally Posted by RudiC
Trying heavily to infer your request from the fragments of orthography that you posted, and presuming a grep with the -A option, I came up with
Code:
date +"%H%MX" | sort - file | grep -A1 X | tail -1
1922

thanks worked for me much appreciated Smilie
# 5  
Old 07-19-2015
You could also try using awk, here we presume your input file is sorted as per the example:

Code:
awk -v NOW=$(date +"%H%M") '$1 > NOW { print ; exit }' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: time intervals based on epoch time

I have a list of epoch times delimited by "-" as follows: 1335078000 - 1335176700 1335340800 - 1335527400 1335771300 - 1335945600 1336201200 - 1336218000 The corresponding dates are: 20120422 1000 - 20120423 1325 20120425 1100 - 20120427 1450 20120430 1035 - 20120502 1100 ... (3 Replies)
Discussion started by: alex2005
3 Replies

2. Shell Programming and Scripting

Convert UTC time into current UNIX sever time zone

Hi guys thanks for the help for my previous posts.Now i have a requirement that i download a XMl file which has UTC time stamp.I need to convert UTC time into Unix server timezone. For ex if the time zone of unix server is CDT then i need to convert into CDT.whatever may be the system time... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

3. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

4. Shell Programming and Scripting

To get the time exactly 24hrs from the current time

Hi guys, I am having file which contains below data. 2012-04-24 08:40:13 10739022730 1027699274PersonInfoShipTO details missing FirstName,LastName, 2012-04-24 08:40:13 10739022730 1027699274PersonInfoShipTO details missing FirstName,LastName, 2012-04-24 08:40:13 ... (2 Replies)
Discussion started by: mohanalakshmi
2 Replies

5. 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

6. Shell Programming and Scripting

IF statement dealing with current time

Hi Guys, I am trying to put together a script that will search a txt file for a timestamp and select all text after the initial one up to EOF but the timestamp searched for will depend on the current date So if it the current time is between 0600 and 0700 the script will search a text file... (7 Replies)
Discussion started by: martin0852
7 Replies

7. Shell Programming and Scripting

How far is given date from current time?

give a date and time: Jun 12 21:05:16 06-12-2012 21:05:16 2012/06/12 21:05:16 How can i subtract these dates and times from the current date and time and get back the difference in seconds? a one liner like: echo "Jun 12 21:05:16" | some perl/awk programming 90900s (2 Replies)
Discussion started by: SkySmart
2 Replies

8. AIX

crontab 1 hour off from current time

This is a new one on me. We upgraded a system from AIX 5.3 TL 7 to 6.1 TL 7 yesterday. The app people notified us that their cron jobs weren't running at the right time. So I made a test cron entry and here's what I've found: # crontab -l * * * * * /usr/bin/date > /tmp/test.log 2>&1 # cat... (2 Replies)
Discussion started by: homeyjoe
2 Replies

9. Shell Programming and Scripting

Conversion from Upper Case to Lower Case Condition based

Hello Unix Gurus : It would be really appreciative if can find a solution for this . I have records in a file . I need to Capitalize the records based on condition . For Example i tried the following Command COMMAND --> fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Discussion started by: tsbiju
12 Replies

10. Shell Programming and Scripting

param as current date+time

Hi All, I need to pass param on aix "errpt -a -s MMDDHHMMYY -e MMDDHHMMYY". How do I read the date+time on the system and pass it as parameter? I need also the -s as previous day and the -e as current day. Thanks, itik (1 Reply)
Discussion started by: itik
1 Replies
Login or Register to Ask a Question