Sponsored Content
Top Forums Shell Programming and Scripting Day of year to dd.mm.yyyy format Post 302598759 by kocaturk on Wednesday 15th of February 2012 10:45:54 AM
Old 02-15-2012
I would firstly like to thank everyone who answered.
I think the missing bit of information was given. Original source file has more than one field and I'm using existing AWK script for formatted output of the source file.
I could not success for formatted output of this field with awk.
two lines of the original file and awk script are below.

Input file lines
-----------------
Code:
62658 2492 308 1 1 2423233672________ 02423233672_______ 902423169300______ 12,046,15:59:58.0 000,00:00:00 046,16:00:00
62659 9232 001 1 1 00306937961503____ 6937961503________ 02123476298_______ 12,046,15:46:59.0 046,15:47:06 046,16:00:00

Code:
awk '
 { 
  for( i = 1; i <= 5; i++ ) printf "%s ", $i
 }
 
 { 
  printf "%-18s %-18s %-18s ", substr($6,1,index($6,"_")-1), substr($7,1,index($7,"_")-1), substr($8,1,index($8,"_")-1)
 }
 
 
 { 
  YEAR = substr($9,1,2)
  DAY = substr($9,4,3)
  DOY=YEAR""DAY
  printf "%s ",system(???????????)
 }
 {
  print ""
 }
' infile.txt >outfile.txt

Output file lines
-----------------
Code:
62658 2492 308 1 1         2423233672        02423233672       902423169300 15.02.2012,15:59:58.0 ------------------- 15.02.2012,16:00:00
62659 9232 001 1 1     00306937961503         6937961503        02123476298 15.02.2012,15:46:59.0 15.02.2012,15:47:06 15.02.2012,16:00:00


Best regards.

Last edited by Franklin52; 02-16-2012 at 03:28 AM.. Reason: Please use code tags for code and data samples, thank you
kocaturk
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get yesterday's date in year-month-day format?

Dear All, Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report. to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for... (2 Replies)
Discussion started by: tiger2000
2 Replies

2. Shell Programming and Scripting

Function to get day of week from YYYY-MM-DD date

Can't find out how to get the day of the week from a given date, anyone got a code snippet that could help please? Ta!! (4 Replies)
Discussion started by: couponmeup
4 Replies

3. AIX

Convert unix timestamp to year month day format ?

Hello, How do I convert unix timestamp value to 'normal' date format - to get year month and day values ? Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ? I don't want to write C program, any ways to do that using unix shells ? thanks (1 Reply)
Discussion started by: vilius
1 Replies

4. Shell Programming and Scripting

Get day of year

Hi, I wold like to know the day of year from a date in input. I know to get this from sysate with date +%j But from a date in input? :confused: Thanks (2 Replies)
Discussion started by: pinguc
2 Replies

5. Shell Programming and Scripting

change date format from yyyy/mm/dd to dd/mm/yyyy

(Attention: Green PHP newbie !) I have an online inquiry form, delivering a date in the form yyyy/mm/dd to my feedback form. If the content passes several checks, the form sends an e-mail to me. All works fine. I just would like to receive the date in the form dd/mm/yyyy. I tried with some code,... (6 Replies)
Discussion started by: keyboarder
6 Replies

6. Shell Programming and Scripting

Converting filenames from julian day to yyyy-mm-dd and retrieving weekly mean values

Hi, I need help to convert the filenames of my 9-year daily files (1999-2007) from a julian day to yyyy-mm-dd format. my original files are patterned likes the ones below. 1999001.txt 1999002.txt 1999003.txt 1999004.txt ... 1999365.txt desired output: 19990101.txt 19990102.txt... (3 Replies)
Discussion started by: ida1215
3 Replies

7. Shell Programming and Scripting

Julian day to dates in YEAR-MONTH-DAY

hello, I have many files called day001, day002, day003 and I want to rename them by day20070101, day20070102, etc. I need to do it for several years and leap years as well. What is the best way to do it ? Thank you. (1 Reply)
Discussion started by: Ggg
1 Replies

8. Shell Programming and Scripting

Pass date (YYYY-MM-DD) as parameter and get Day

Hi, I have a requirement where I have to pass Date to a script and get the day from it. Ex If parameter is 2015-09-29 The output should be Tuesday. Can you please tell me how to get that? (6 Replies)
Discussion started by: ashwin3086
6 Replies

9. Shell Programming and Scripting

Date format YYYY/MM/DD to DD/MM/YYYY

I am getting output of YYYY-MM-DD and want to change this to DD/MM/YYYY. When am running the query in 'Todd' to_date(column_name,'DD/MM/YYYY') am getting the required o/p of DD/MM/YYYY, But when am executing the same query(Netezza) in linux server(bash) am getting the output of YYYY-MM-DD file... (3 Replies)
Discussion started by: Roozo
3 Replies
TZSELECT(8)						      System Manager's Manual						       TZSELECT(8)

NAME
tzselect - select a time zone SYNOPSIS
tzselect DESCRIPTION
The tzselect program asks the user for information about the current location, and outputs the resulting time zone description to standard output. The output is suitable as a value for the TZ environment variable. All interaction with the user is done via standard input and standard error. ENVIRONMENT VARIABLES
AWK Name of a Posix-compliant awk program (default: awk). TZDIR Name of the directory containing time zone data files (default: /usr/local/etc/zoneinfo). FILES
TZDIR/iso3166.tab Table of ISO 3166 2-letter country codes and country names. TZDIR/zone.tab Table of country codes, latitude and longitude, TZ values, and descriptive comments. TZDIR/TZ Time zone data file for time zone TZ. EXIT STATUS
The exit status is zero if a time zone was successfully obtained from the user, nonzero otherwise. SEE ALSO
newctime(3), tzfile(5), zdump(8), zic(8) TZSELECT(8)
All times are GMT -4. The time now is 10:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy