![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare date from db2 table to yesterday's Unix system date | sasaliasim | Shell Programming and Scripting | 9 | 1 Day Ago 08:37 PM |
| Perl: Extracting date from file name and comparing with current date | MKNENI | Shell Programming and Scripting | 4 | 03-26-2008 01:01 PM |
| date issue-find prevoius date in a patricular format | bsandeep_80 | UNIX for Advanced & Expert Users | 3 | 11-15-2007 05:42 PM |
| Changing Creation Date to a Prespecified Date of a File In Unix | monkfan | UNIX for Dummies Questions & Answers | 4 | 11-28-2006 04:15 AM |
| Specify a previous date as start date in shell script | ritzwan0 | Shell Programming and Scripting | 2 | 09-25-2006 02:58 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi everybody:
I'm trying to create files database, and to do this I'd like to create them with this format: date hour julian-day SZA other-values from the original file I've this format: - , year, julian-day, minute, other-values 112,2004,84,2300,-3.352,,,,,,,,,,, To do this I'd created this awk-script: # # here there are different format staments # # gregorian date conversion { if($3 <= 31) dg = $3; mm=01; # january if($3 > 31 && $3 <=59) dg = $3-31; mm = 02; # february if($3 > 59 && $3 <=90) dg = $3-59; mm = 03; # march if($3 > 90 && $3 <=120) dg = $3-90; mm = 04; # april if($3 > 120 && $3 <=151) dg = $3-120; mm = 05; # may if($3 > 151 && $3 <=181) dg = $3-151; mm = 06; # juny if($3 > 181 && $3 <=212) dg = $3-181; mm = 07; # july if($3 > 212 && $3 <=243) dg = $3-212; mm = 08; # august if($3 > 243 && $3 <=273) dg = $3-243; mm = 09; # september if($3 > 273 && $3 <=304) dg = $3-273; mm = 10; # octuber if($3 > 304 && $3 <=334) dg = $3-304; mm = 11; # november if($3 > 334 && $3 <=365) dg = $3-334; mm = 12; # december }; # hour format { if ($4 <=9 ) $4 = 000$4; if ($4 >=10 && $4 <=59 ) $4 = 00$4; if ($4 >=100 && $4 <=959 )$4 = 0$4; }; and the output I'd like this: # print final file with format { printf format, $2 mm dg, $4, $3, SZA, $5, $6, $7, $8, $9, $10, $11, $12, $13 }' abr01_04.mpy > abr01_04.csv and I've this: 20041226 00 85 136.11934 -2.595 -2.697 .044 25.31 -1.19 5.334 1.058 .197 .096 20041226 01 85 136.11934 -2.766 -2.588 .044 25.42 -1.19 5.382 .753 .205 .193 20041226 02 85 136.11934 -2.984 -2.429 .044 25.37 -1.189 5.405 .896 .197 .116 20041226 03 85 136.11934 -2.98 -2.419 .044 25.31 -1.189 5.41 .789 .183 .125 20041226 04 85 136.11934 -3.005 -2.344 .044 25.42 -1.193 5.418 .914 .234 .141 First I don't know why the format date the month doesn't appear correctly, in this case it must be 05-april cause julian day is 85, and in the other hand the hour format doesn't appear as I'd like, because in this case it is 00 where it must be 0000. Could anybody tell me how solve it?. Thanks in advance. |
|||
| Google The UNIX and Linux Forums |
| Forum Sponsor | ||
|
|