Sponsored Content
Top Forums Shell Programming and Scripting To get the time exactly 24hrs from the current time Post 302829993 by Chubler_XL on Sunday 7th of July 2013 05:49:26 PM
Old 07-07-2013
Since your date format is sortable you could calculate the 24hour time using perl and then use a simple nawk script like this:

24hr.pl
Code:
#!/bin/perl
use POSIX; print strftime('%Y-%m-%d %H:%M:%S', localtime(time() - 24*60*60));

Then use this (24hr.pl executable and in current directory):
Code:
FROM=`./24hr.pl`
awk "\$0 > \"$FROM\"" infile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Substituting variable with current time

Hi all I have a script as follows :- #!/usr/bin/ksh IDT=`date +"%OH%M%S"` while true do echo ${IDT} sleep 1 done I need the time to show me the current runtime value for the time, however this returns the time as at the start of the script. Any ideas. Thanks JH (4 Replies)
Discussion started by: jhansrod
4 Replies

2. Shell Programming and Scripting

getting hour minus the current time

Can some one help me getting last hour of the current time with date command in a script. (7 Replies)
Discussion started by: shehzad_m
7 Replies

3. Shell Programming and Scripting

Getting current time from wolfram.com using python

Hello to all, I am looking of a python script that can fetch date & time from wolfram or any website that gives correct time. 1. Open woflram.com website 2. Search query "time" 3. Search result displays the time. The script has to contact the website with the search query, take that... (5 Replies)
Discussion started by: frozensmilz
5 Replies

4. UNIX for Dummies Questions & Answers

getting the current time in Epoch format

Hi everybody, I want to get the current time in epoch format (in UNIX or Korn Shell) and store it in a variable called currentTime. Any response will be highly appreciated:) Thanks in advance, omoyne:D (8 Replies)
Discussion started by: omoyne
8 Replies

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

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

7. UNIX for Dummies Questions & Answers

Change time with current year

Hi, How can i change the time below (red font) with the current year? Thank You in advance. hostname 2007-Feb-9 /u100/DEVCO/Patching a.log hostname 2010-Jun-25 /u100/DEVCO/DumpCleaner a.log hostname 2011-Jun-25 /u100/DEVCO/DumpCleaner/sample a.log hostname 23:44-Jun-25... (2 Replies)
Discussion started by: lienyca
2 Replies

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

9. Shell Programming and Scripting

Add current date and time

i have file 1.txt asdas|csada|13|03|10|04|23|A1|canberra sdasd|sfdsf|13|04|26|23|28|A1|sydney i want to add today's date and time in the end of each row expected output asdas|csada|13|03|10|04|23|A1|canberra|130430|1358 sdasd|sfdsf|13|04|26|23|28|A1|sydney|130430|1358 todays date... (10 Replies)
Discussion started by: radius
10 Replies

10. 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
Data::Faker::DateTime(3pm)				User Contributed Perl Documentation				Data::Faker::DateTime(3pm)

NAME
Data::Faker::DateTime - Data::Faker plugin SYNOPSIS AND USAGE
See Data::Faker DATA PROVIDERS
unixtime Return a unix time (seconds since the epoch) for a random time between the epoch and now. date Return a random date as a string, using a random date format (see date_format). time Return a random time as a string, using a random time format (see time_format). rfc822 Return an RFC 822 formatted random date. This method may not work on systems using a non-GNU strftime implementation (kindly let me know if that is the case.) ampm Returns am or pm randomly (in the current locale) using one of the formats specified in ampm_format. time_format Return a random time format. date_format Return a random date format. ampm_format Return a random am/pm format. datetime_format Return a random date and time format. month Return a random month name, unabbreviated, in the current locale. month_abbr Return a random month name, abbreviated, in the current locale. weekday Return a random weekday name, unabbreviated, in the current locale. weekday_abbr Return a random weekday name, abbreviated, in the current locale. sqldate Return a random date in the ISO8601 format commonly used by SQL servers (YYYY-MM-DD). datetime_locale Return a datetime string in the preferred date representation for the current locale, for a random date. date_locale Return a date string in the preferred date representation for the current locale, for a random date. time_locale Return a time string in the preferred date representation for the current locale, for a random date. century Return a random century number. dayofmonth Return a random day of the month. UTILITY METHODS
Data::Faker::DateTime::timestr($format); Given a strftime format specifier, this method passes it through to POSIX::strftime along with a random date to display in that format. Perl passes this through to the strftime function of your system library, so it is possible that some of the formatting tokens used here will not work on your system. NOTES AND CAVEATS
Be careful build timestamps from pieces Be very careful about building date/time representations in formats that are not already listed here. For example if you wanted to get a date that consists of just the month and day, you should NOT do this: my $faker = Data::Faker->new(); print join(' ',$faker->month,$faker->dayofmonth)." "; This is bad because you might end up with 'February 31' for example. Instead you should use the timestr utility function to provide you a formatted time for a valid date, or better still, write a plugin function that does it: my $faker = Data::Faker->new(); print $faker->my_short_date()." "; package Data::Faker::MyExtras; use base qw(Data::Faker); use Data::Faker::DateTime; __PACKAGE__->register_plugin( my_short_date => sub { Data::Faker::DateTime::timestr('%M %e') }, ); POSIX::strftime See the documentation above regarding the timestr utility method for some caveats related to strftime and your system library. SEE ALSO
Data::Faker AUTHOR
Jason Kohles, <email@jasonkohles.com> COPYRIGHT AND LICENSE
Copyright 2004-2005 by Jason Kohles This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2005-07-14 Data::Faker::DateTime(3pm)
All times are GMT -4. The time now is 07:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy