Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Help in expandi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 2127 of 2297
Post > Topic >>

Help in expanding array substitution more than 9 in script.

by i_robot73@[EMAIL PROTECTED] Jan 10, 2008 at 11:53 AM

'base' file:

....
Cap\FY<YEAR>\<YEAR>*.xls" INC,NONREC;
Cap\FY<YEAR>\MMM\Day-13*.xls" INC,NONREC;
Cap\FY<YEAR>\MMM\Day-12*.xls" INC,NONREC;
Cap\FY<YEAR>\MMM\Day-11*.xls" INC,NONREC;
Cap\FY<YEAR>\MMM\Day-10*.xls" INC,NONREC;
Cap\FY<YEAR>\MMM\Day-9*.xls" INC,NONREC;
Cap\FY<YEAR>\MMM\Day-8*.xls" INC,NONREC;
....


Script:

BEGIN{
	ShortM = strftime( "%b" )
	FullY =  strftime( "%Y" )
	LineCount = 0
        Now = systime()
        SecondsPerDay = 60 * 60 * 24
	#
	# List, from 14 days ago, until today
	#
        for( x = 14; x >= 0; x-- ) {
                Table[ x ] = strftime( "%m%d%Y", Now - (SecondsPerDay
* x ) )
		print Table [ x ]
        }
}
{
	#
	# Substitute 'Day-X' for acutal dates
	#
        if( match( $0, /Day-([0-13])*/, Arr ) ) {
                sub( Arr[ 0 ], Table[ Arr[ 1 ] ])
		print Arr [ 0 ], " - " Table[ Arr[ 1 ] ]
        }
	gsub( /<YEAR>/, FullY )      # Substitute ALL '<YEAR>' instances for
actual year
	gsub( /MMM/, ShortM )        # Substitute ALL occurrences of 'MMM'
for short month notation
        Array[ ++LineCount ] = $0
}

END{
        close( FILENAME )	     # File read into array, close it
				     #    so it can be over-written if need be
        for( x = 1; x <= LineCount; x++ ) print Array[ x ]
        delete Array
}



Unfort. 0-9 works 100%...Anything 10+; the subst & replace just hoses
up.  Day-[11-12]. is the same as Day-1.  What modifications would I
need to do to get this to, again, give me a 1:1 replacement??
 




 5 Posts in Topic:
Help in expanding array substitution more than 9 in script.
i_robot73@[EMAIL PROTECTE  2008-01-10 11:53:30 
Re: Help in expanding array substitution more than 9 in script.
Ted Davis <tdavis@[EMA  2008-01-10 15:17:47 
Re: Help in expanding array substitution more than 9 in script.
Ed Morton <morton@[EMA  2008-01-10 19:34:53 
Re: Help in expanding array substitution more than 9 in script.
i_robot73@[EMAIL PROTECTE  2008-01-14 07:11:15 
Re: Help in expanding array substitution more than 9 in script.
pop <p_o_p@[EMAIL PROT  2008-01-14 11:20:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 20:42:13 CDT 2008.