Sponsored Content
Top Forums UNIX for Advanced & Expert Users [SOLVED] Making mktime/strftime available to mawk Post 302882715 by treesloth on Wednesday 8th of January 2014 06:03:20 PM
Old 01-08-2014
Quote:
Originally Posted by Corona688
Well, what is your system? does it have mktime and strftime?

The first thing that comes to mind is upgrading your version of mawk.
Thanks for the reply. I'm running CentOS 6.0 x86_64. I'm very sorry to say I don't know how to determine whether it has mktime and strftime. How would I do that?

Also, while the unix.com man page library does have a mawk entry, it appears to differ from the one I linked, lacking at least the time-related entries I cited. Is it still ok to link externally in that case?

Again, thanks for the help.

Last edited by treesloth; 01-08-2014 at 07:12 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

gawk and strftime()

Strange behaviour of the strftime() function from gawk (3.1.5): $ awk 'BEGIN{print strftime("%T", 3600)}' > 02:00:00 $ awk 'BEGIN{print strftime("%T", 0)}' > 01:00:00 Obviously something with DST but I can not figure out why? To me 3600 epoch seconds remains 01:00, DST or not. From... (2 Replies)
Discussion started by: ripat
2 Replies

2. UNIX for Dummies Questions & Answers

mawk script to compare 2 files and report where they match

I have two files and would like a report of where they match. Example of file1: 1 1 1 2 2 2 13 14 15 4 4 4 15 16 17 100 102 1004 56 57 890 Example of file2: 2 2 2 16 10 11 45 22 35 13 14 15 1001 1002 3456 100 102 1004 (1 Reply)
Discussion started by: kenneth.mcbride
1 Replies

3. Shell Programming and Scripting

MAWK does not support length(array)?

As Brendan O'Conner writes in this blog, mawk is near 8 times faster than gawk, so I am going to give mawk a go, but I got errors when trying to print the length of an array in mawk using length() function, is it not supported in mawk? or there's another way to get the length of an array in mawk? ... (3 Replies)
Discussion started by: kevintse
3 Replies

4. Programming

strftime equivalent in c++

HI, i wish to convert a millsec value to a readable string format. the one option is to use strftime. However this is a bit costly (1-5 micros). is there a a faster way to do so with just string manipulation (Note i have the date object which has the time details but wish o avoid strftime) (2 Replies)
Discussion started by: wojtyla
2 Replies

5. Shell Programming and Scripting

[Solved] making each word of a line to a separate line

Hi, I have a line which has n number of words with separated by space. I wanted to make each word as a separate line. for example, i have a file that has line like i am a good boy i want the output like, i am a good (8 Replies)
Discussion started by: rbalaj16
8 Replies

6. UNIX for Dummies Questions & Answers

[Solved] Making a text based game

Hello, I am looking to make a text based game, that runs in the command window, or a window similar. I will only need to use 1 window. I read somewhere that there is libraries for this kind of thing? But I can't remember the name of them.. Can anyone point me in a direction? I will be... (2 Replies)
Discussion started by: murphy
2 Replies

7. Shell Programming and Scripting

Compute in milisecond by use of mktime

Hi, I want to calculate diff b/w these starttime and endtime with use of mktime. I need response time in milisecond. I am using mktime to get these times. last three digits are in milisecond Starttime 2013-04-03 08:54:19,989 End time 2013-04-03 08:54:39,389 (9 Replies)
Discussion started by: random_thoughts
9 Replies

8. Shell Programming and Scripting

Help on awk strftime

cat file 41285.000034722223 41285.000567129631 41285.000069444446 41285.001122685186 41285.000092592592 41285.001620370371 41285.000138888892 41285.00340277778 41285.000185185185 41285.000405092593 41285.000196759262 41285.000856481478 41285.000208333331 41285.000717592593... (5 Replies)
Discussion started by: phpshell
5 Replies

9. UNIX for Advanced & Expert Users

Mawk printf %d maxes out at 2147483647

So, I do some file processing that generates very large numbers, such as total amount GETted from a busy web cluster in a month, etc. Mawk is awesome-- fast and easy. It's awk! But, there's a fatal flaw that I'd like to overcome. Apparently, %d maxes out at 2147483647. Here's sample output,... (11 Replies)
Discussion started by: treesloth
11 Replies

10. Shell Programming and Scripting

awk mktime(strftime(format,"6-FEB-2013 08:50:03.841")

I'm trying to use AWK to filter on some dates in a field by converting them to Unix Time. mktime(strftime(format,"6-FEB-2013 08:50:03.841")What is the proper format for my date strings as they appear in my database? My first thought is %d-%b-%Y %H:%M:%Sbut I see the following issues: %d is... (3 Replies)
Discussion started by: Michael Stora
3 Replies
MKTIME(3P)						     POSIX Programmer's Manual							MKTIME(3P)

PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the correspond- ing Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. NAME
mktime - convert broken-down time into time since the Epoch SYNOPSIS
#include <time.h> time_t mktime(struct tm *timeptr); DESCRIPTION
The mktime() function shall convert the broken-down time, expressed as local time, in the structure pointed to by timeptr, into a time since the Epoch value with the same encoding as that of the values returned by time(). The original values of the tm_wday and tm_yday com- ponents of the structure are ignored, and the original values of the other components are not restricted to the ranges described in <time.h>. A positive or 0 value for tm_isdst shall cause mktime() to presume initially that Daylight Savings Time, respectively, is or is not in effect for the specified time. A negative value for tm_isdst shall cause mktime() to attempt to determine whether Daylight Savings Time is in effect for the specified time. Local timezone information shall be set as though mktime() called tzset(). The relationship between the tm structure (defined in the <time.h> header) and the time in seconds since the Epoch is that the result shall be as specified in the expression given in the definition of seconds since the Epoch (see the Base Definitions volume of IEEE Std 1003.1-2001, Section 4.14, Seconds Since the Epoch) corrected for timezone and any seasonal time adjustments, where the names in the structure and in the expression correspond. Upon successful completion, the values of the tm_wday and tm_yday components of the structure shall be set appropriately, and the other components are set to represent the specified time since the Epoch, but with their values forced to the ranges indicated in the <time.h> entry; the final value of tm_mday shall not be set until tm_mon and tm_year are determined. RETURN VALUE
The mktime() function shall return the specified time since the Epoch encoded as a value of type time_t. If the time since the Epoch cannot be represented, the function shall return the value (time_t)-1. ERRORS
No errors are defined. The following sections are informative. EXAMPLES
What day of the week is July 4, 2001? #include <stdio.h> #include <time.h> struct tm time_str; char daybuf[20]; int main(void) { time_str.tm_year = 2001 - 1900; time_str.tm_mon = 7 - 1; time_str.tm_mday = 4; time_str.tm_hour = 0; time_str.tm_min = 0; time_str.tm_sec = 1; time_str.tm_isdst = -1; if (mktime(&time_str) == -1) (void)puts("-unknown-"); else { (void)strftime(daybuf, sizeof(daybuf), "%A", &time_str); (void)puts(daybuf); } return 0; } APPLICATION USAGE
None. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
asctime(), clock(), ctime(), difftime(), gmtime(), localtime(), strftime(), strptime(), time(), utime(), the Base Definitions volume of IEEE Std 1003.1-2001, <time.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 MKTIME(3P)
All times are GMT -4. The time now is 10:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy