Sponsored Content
Top Forums Shell Programming and Scripting gawk convert 2012-Jun-13 to 2012-06-13 Post 302655585 by trey85stang on Wednesday 13th of June 2012 11:26:33 AM
Old 06-13-2012
gawk convert 2012-Jun-13 to 2012-06-13

I have a value in a file i am processing that has a date like "2012-Jun-13"

how can I convert a date like that 2012-06-13?

Am I stuck building an array of three digit months and corresponding numbers and running through the logic of figuring out the number??

or can I convert this with strftime? if so I cant figure out how... Im also cool with dropping down to the shell level and using gnu date to do this. But I dont know how to pull a system call back into gawk as a variable.

Any ideas?

---------- Post updated at 10:26 AM ---------- Previous update was at 10:17 AM ----------

I found another post details what I need to do this with a system call..

Quote:
Originally Posted by fbg

I could find the answer in other post. Need to do:

echo 40 | awk ' { comm="test.sh "$1; comm | getline y; close(comm); print y } '

Is a nice trick
If anyone knows how to do this without a system call, i would still like to know.

Thanks,
Trey
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do i compare two dates with format Jan 01, 2012 and Jan 00 2012

I need to be able to compare dates in the format of Jan 10, 2012 and Jan 10 2012. (Notice one has a comma). Then I need to find the date that is 7 days before those dates if they are equal. How can I do this in Bash. Thank ahead (4 Replies)
Discussion started by: ojthejuice
4 Replies

2. Post Here to Contact Site Administrators and Moderators

Event Prediction - Euro 2012

Please add this new "event". (10 Replies)
Discussion started by: ni2
10 Replies

3. What is on Your Mind?

Tennis - Wimbledon 2012

For those of you watching Wimbledon you already know that Rafael Nadal will not be in the final. There is an open event in the Event Prediction Forum. Place your bits on the guys left. This event closes on Sunday 8th July 2012. (0 Replies)
Discussion started by: ni2
0 Replies

4. Shell Programming and Scripting

Date conversion help from dd/mm/yyyy to dd/Mon/yyyy i.e. 28/10/2012 to 28/Oct/2012

Hi I have a problem with Date format in my code. 1st I am trying to convert today's date to yesterday's using YESTERDAY3=`perl -e '@y=localtime(time()-86400); printf "%04d/%02d/%02d",$y+1900,$y+1,$y;$y;'` And once it is done I am trying to using the yesterday date in a grep command to... (3 Replies)
Discussion started by: nithinankam
3 Replies

5. What is on Your Mind?

Place your bits - 2012 FIFA Ballon d'Or and 2012 FIFA World Coach of the Year

I have added two new sports events. The FIFA Ballon d'Or is an association football award given annually to the player who is considered to have performed the best in the previous season. It is awarded based on votes by coaches and captains of international teams, as well as journalists from... (0 Replies)
Discussion started by: ni2
0 Replies

6. HP-UX

HP ux 11i v3 september 2012 Media

Hello Friends, I bought HP-UX 9000 series server. They shipped it with HP-UX 11.31 March 2014 version operating system. But i want to reload it with HP ux 11i v3 september 2012. I have only hardware support for this box, so i cant get it from HP site. Can any tell me where can i download it.... (4 Replies)
Discussion started by: corequad
4 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWgawk | +--------------------+-----------------+ |Interface Stability | Volatile | +--------------------+-----------------+ NOTES
Source for gawk is available on http://opensolaris.org. Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 07:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy