Please help!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help!!!
# 8  
Old 07-20-2006
The missing ) character in red:

Quote:
Originally Posted by mhssatya
Hi Vgersh,

I am getting an error like this

awk '{data[NR] = $0; out= FILENAME "new"; file[NR]=out;} END { if ( NR -
2 == $1) { for ( i=2 ; i < NR; i++ ) { print data[i]} > file[i];
close(file[i])}else { print "error"} }' arun* syntax error The source
line is 1.
......
# 9  
Old 07-20-2006
I was checking this for interest and I got an error similar to what mhssatya got.. Below is the error I got too.

syntax error The source line is 1.
The error context is
{data[NR] = $0; out= FILENAME "new"; file[NR]=out;} END { if ( NR - 2 == $1) { for ( i=2 ; i < NR; i++ ) { print data[i]} >>> > <<< file[i]; close(file[i])}else { print "error"} }
awk: The statement cannot be correctly parsed.
The source line is 1.
# 10  
Old 07-20-2006
Make sure you used the code exactly as Klashxx corrected it.

if that doesn't work, try nawk in place of awk.
# 11  
Old 07-20-2006
Reborg,

I am trying exactly as klashxx told but I got the error again and when I used nawk I got nawk: not found error.

I created 2 files as arun and arun1 like this:
arun:
run
1
1
2

arun1:

run
1
1
2

and i ran the code but it didn;t work. I am getting error as mhssatya got. I don't know whether he is getting the same error or not.
# 12  
Old 07-20-2006
Reborg,

I am getting the same error as sravan is getting and also I need to do the processing for 30 files at the same time and write them to 30 new files if the count in each of them matches the record count in each of the files. I need to append _new to old file. For eg if the file names is

CARE01_DLY_MKT_YYYYMMDD then if the count matches to the data rows in the file then I need to write this to a new file with the only data rows with file name CARE01_DLY_MKT_YYYYMMDD _new.

This has to be repeated for all the 30 files in the directory. So how can I acheive this. Please help
# 13  
Old 07-20-2006
Code:
awk '{data[FNR] = $0; out=FILENAME "_new"; file[FNR]=out;} END { if ( FNR - 2 == $1) { for ( i=2 ; i < FNR; i++ ) { print data[i]  > file[i]}  close(file[i])}else { print "error"} }' CARE01_DLY_???_`date+%Y%m%d`


Last edited by reborg; 07-20-2006 at 07:14 PM..
# 14  
Old 07-20-2006
Reborg,

In the file name only CARE01_DLY_MKT_YYYYMMDD only MKT changes for all the files. For e.g like CARE01_DLY_IRL_20060720 for 1st file, CARE01_DLY_IND_20060720 for 2nd file like that.

So what do i need to specify as file name in the code. I don't know where to give the name in the code. Please suggest
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question