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
holidays(4)							   File Formats 						       holidays(4)

NAME
holidays - prime/nonprime table for the accounting system SYNOPSIS
/etc/acct/holidays DESCRIPTION
The /etc/acct/holidays file specifies prime time hours and holidays. Holidays and weekends are considered non-prime time hours. /etc/acct/holidays is used by the accounting system. All lines beginning with an * are comments. The /etc/acct/holidays file consists of two sections. The first non-comment line defines the current year and the start time of prime and non-prime time hours, in the form of: current_year prime_start non_prime_start Specify prime_start and non_prime_start times in the range of 0000 to 2400. The remaining non-comment lines define the holidays in the form of: month/day company_holiday Of these two fields, only the month/day is actually used by the accounting system programs. The /etc/acct/holidays file must be updated every year. EXAMPLES
Example 1 An Example of the /etc/acct/holidays File The following is an example of the /etc/acct/holidays file: * Prime/Nonprime Table for the accounting system * * Curr Prime Non-Prime * Year Start Start * 1991 0830 1800 * * only the first column (month/day) is significant. * * month/day Company Holiday * 1/1 New Years Day 5/30 Memorial Day 7/4 Indep. Day 9/5 Labor Day 11/24 Thanksgiving Day 11/25 day after Thanksgiving 12/25 Christmas 12/26 day after Christmas SEE ALSO
acct(1M) SunOS 5.11 18 Aug 2008 holidays(4)
All times are GMT -4. The time now is 12:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy