02-01-2010
how to increment days according to year & month
Hiii i have a file with data as shown below:
a.dat:
HTML Code:
RAO 1900 2 7 0 0 0.00 10.8000 76.8000 10.0 0 0.00 0 6.00 0.00 0.00 0 0.00 6.00 0 NULL
LEE 1901 2 15 0 0 0.00 26.0000 100.0000 0.0 0 0.00 0 0.00 0.00 0.00 0 6.00 6.00 0 NULL
RAO 1901 4 27 0 0 0.00 12.0000 75.0000 10.0 0 0.00 0 5.00 0.00 0.00 0 0.00 5.00 0 NULL
SSR 1901 12 1 0 0 0.00 37.8000 66.2000 14.0 0 0.00 0 4.60 0.00 0.00 0 0.00 4.60 0 NULL
SSR 1902 4 17 21 10 0.00 40.0000 71.0000 30.0 0 0.00 0 5.80 0.00 5.90 0 5.70 5.90 0 NULL
SSR 1902 8 12 17 16 0.00 39.5000 68.5000 35.0 0 0.00 0 6.00 0.00 6.20 0 5.90 6.20 0 NULL
BDA 1902 8 22 3 0 0.00 40.0000 77.0000 60.0 0 0.00 0 0.00 0.00 0.00 0 8.60 8.60 0 NULL
SIG 1902 8 22 3 1 0.00 39.8000 76.2000 40.0 0 0.00 0 0.00 0.00 0.00 0 8.10 8.10 1 NULL
SIG 1902 8 30 21 50 0.00 37.0000 71.0000 200.0 0 0.00 0 0.00 0.00 0.00 0 7.70 7.70 0 NULL
SSR 1902 9 20 6 32 0.00 38.5000 67.0000 40.0 0 0.00 0 6.20 0.00 6.30 0 6.10 6.30 0 NULL
SSR 1902 10 6 9 15 0.00 36.5000 70.5000 200.0 0 0.00 0 7.20 0.00 6.50 0 7.10 7.20 0 NULL
SSR 1902 12 4 22 18 0.00 37.8000 65.5000 20.0 0 0.00 0 4.90 0.00 0.00 0 0.00 4.90 0 NULL
RAO 1903 1 14 0 0 0.00 24.0000 70.0000 10.0 0 0.00 0 6.00 0.00 0.00 0 0.00 6.00 0 NULL
SSR 1903 1 20 8 24 0.00 37.0000 71.0000 30.0 0 0.00 0 5.50 0.00 0.00 0 0.00 5.50 0 NULL
SSR 1903 4 19 13 25 0.00 37.0000 71.0000 160.0 0 0.00 0 6.90 0.00 6.20 0 6.90 6.90 0 NULL
SSR 1903 5 16 6 18 0.00 5.3600 92.5000 11.0 0 0.00 0 4.50 0.00 0.00 0 0.00 4.50 0 NULL
RAO 1903 5 17 0 0 0.00 23.0000 80.0000 10.0 0 0.00 0 4.30 0.00 0.00 0 0.00 4.30 0 NULL
SSR 1903 10 19 3 10 0.00 39.3000 74.5000 25.0 0 0.00 0 6.20 0.00 0.00 0 0.00 6.20 0 NULL
SSR 1904 2 4 21 0 0.00 40.0000 78.0000 30.0 0 0.00 0 6.10 0.00 5.90 0 6.20 6.20 0 NULL
The output should be as follows
b.dat:
HTML Code:
RAO 1900 2 38 0 0 0.00 10.8000 76.8000 10.0 0 0.00 0 6.00 0.00 0.00 0 0.00 6.00 0 NULL
LEE 1901 2 411 0 0 0.00 26.0000 100.0000 0.0 0 0.00 0 0.00 0.00 0.00 0 6.00 6.00 0 NULL
RAO 1901 4 482 0 0 0.00 12.0000 75.0000 10.0 0 0.00 0 5.00 0.00 0.00 0 0.00 5.00 0 NULL
SSR 1901 12 700 0 0 0.00 37.8000 66.2000 14.0 0 0.00 0 4.60 0.00 0.00 0 0.00 4.60 0 NULL
SSR 1902 4 837 21 10 0.00 40.0000 71.0000 30.0 0 0.00 0 5.80 0.00 5.90 0 5.70 5.90 0 NULL
SSR 1902 8 954 17 16 0.00 39.5000 68.5000 35.0 0 0.00 0 6.00 0.00 6.20 0 5.90 6.20 0 NULL
BDA 1902 8 964 3 0 0.00 40.0000 77.0000 60.0 0 0.00 0 0.00 0.00 0.00 0 8.60 8.60 0 NULL
SIG 1902 8 964 3 1 0.00 39.8000 76.2000 40.0 0 0.00 0 0.00 0.00 0.00 0 8.10 8.10 1 NULL
SIG 1902 8 972 21 50 0.00 37.0000 71.0000 200.0 0 0.00 0 0.00 0.00 0.00 0 7.70 7.70 0 NULL
SSR 1902 9 993 6 32 0.00 38.5000 67.0000 40.0 0 0.00 0 6.20 0.00 6.30 0 6.10 6.30 0 NULL
SSR 1902 10 1009 6 9 15 0.00 36.5000 70.5000 200.0 0 0.00 0 7.20 0.00 6.50 0 7.10 7.20 0 NULL
SSR 1902 12 1068 22 18 0.00 37.8000 65.5000 20.0 0 0.00 0 4.90 0.00 0.00 0 0.00 4.90 0 NULL
RAO 1903 1 1109 0 0 0.00 24.0000 70.0000 10.0 0 0.00 0 6.00 0.00 0.00 0 0.00 6.00 0 NULL
SSR 1903 1 1115 8 24 0.00 37.0000 71.0000 30.0 0 0.00 0 5.50 0.00 0.00 0 0.00 5.50 0 NULL
SSR 1903 4 1204 13 25 0.00 37.0000 71.0000 160.0 0 0.00 0 6.90 0.00 6.20 0 6.90 6.90 0 NULL
SSR 1903 5 1231 6 18 0.00 5.3600 92.5000 11.0 0 0.00 0 4.50 0.00 0.00 0 0.00 4.50 0 NULL
RAO 1903 5 1232 0 0 0.00 23.0000 80.0000 10.0 0 0.00 0 4.30 0.00 0.00 0 0.00 4.30 0 NULL
SSR 1903 10 1387 3 10 0.00 39.3000 74.5000 25.0 0 0.00 0 6.20 0.00 0.00 0 0.00 6.20 0 NULL
SSR 1904 2 1495 21 0 0.00 40.0000 78.0000 30.0 0 0.00 0 6.10 0.00 5.90 0 6.20 6.20 0 NULL
i.e. Based on on year & month date must be incremented. For example: for 1901 it 365+31(january)+15 & so on etc...
Help me out if any idea
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Friends,
I'm doing on script which finds all the files with time stamp and makes them tar and zip, based on their respective month&year. for instance "mar-2004.tar.zip" will contain all the files which was created/accessed/modified on mar-2004. like this the entire filesystem should be taken... (1 Reply)
Discussion started by: tuxfello
1 Replies
2. UNIX for Advanced & Expert Users
how to get the last month and year in UNIx (2 Replies)
Discussion started by: Vijay06
2 Replies
3. Programming
Hi,
I'm working on a Informix4gl module. I'm just trying to find out any built-in function to fetch only the year/month from an INTERVAL YEAR TO MONTH data value.
Please let me know, if there are any functions to do this. If not, let me know for any alternative solutions to attain this.
... (5 Replies)
Discussion started by: dvah
5 Replies
4. Shell Programming and Scripting
Hi
I have files like
abc_cd_20110302_123423
abc_cd_ef_20110301_123423
abc_cd_ef_20110403_123423
abc_ef_20110401_123423
I want to extract the
the year and month associated with each file.
I tried
logfileyearmonth=`echo $logfile | awk -F_'{print $NF}'`
Any other way can I... (6 Replies)
Discussion started by: dgmm
6 Replies
5. UNIX for Dummies Questions & Answers
I have created this program to get the next month and year. Is there a simpler way.
#!/bin/ksh
string=`cat Date.txt`
year=`echo $string | cut -c 1-4`
month=`echo $string | cut -c 5-6`
echo $year$month
mon=`expr $month + 1`
if ; then
mon=0$mon
echo $mon
fi
if ; then
month=01
... (2 Replies)
Discussion started by: w020637
2 Replies
6. Shell Programming and Scripting
Hi All,
I need to find all files other than first two files dates & last file date for month and month/year wise list.
lets say there are following files in directory
Mar 19 2012 c.txt
Mar 19 2012 cc.txt
Mar 21 2012 d.txt
Mar 22 2012 f.txt
Mar 24 2012 h.txt
Mar 25 2012 w.txt
Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies
7. Shell Programming and Scripting
Hi All,
I find all files for same month and year
lets say there are following files in directory
-rwxr-xr-x 1 user userg 1596 Mar 19 2012 c.txt
-rwxr-xr-x 1 user userg 1596 Mar 21 2012 d.txt
-rwxr-xr-x 1 user userg 1596 Mar 22 2012 f.txt
-rwxr-xr-x 1... (8 Replies)
Discussion started by: Makarand Dodmis
8 Replies
8. Shell Programming and Scripting
how to find all files other than first two dates & last date per month and year
Hi All,
lets say there are following files in directory
-rwxr-xr-x 1 user userg 1596 Mar 19 2012 a.txt
-rwxr-xr-x 1 user userg 1596 Mar 19 2012 b.txt
-rwxr-xr-x 1 user userg ... (6 Replies)
Discussion started by: Makarand Dodmis
6 Replies
9. UNIX for Beginners Questions & Answers
Hi Folks -
I'm looking for the best way to to increment fiscal weeks - allow me to explain.
At my one client, 10/01/17 was the beginning if year fiscal year 2018.
Each week, I need to manage a unique set of variable that are updated in my application - they are called substitution variables.... (31 Replies)
Discussion started by: SIMMS7400
31 Replies