I gotten this script down to accomplish what I need, but it the csplit command is limited to 99 iterations on AIX/ksh.
I have a large file that is a reprint of a bunch of invoices. I need to split the file into a seperate file for each invoice and then rename it using the invoice number from inside the file.
Here's what I have right now. I know it's not the prettiest...
csplit -s -k -finv -n4 /REPORTS/TEMPINV.TXT /PROF/+2 {99}
for FILE in $(ls inv*)
do
INV=$(head -20 $FILE| grep "[0-9][0-9]/[0-9][0-9]/[0-9][0-9]"|awk '{ pr
int $1 }')
mv $FILE "$INV".txt
done
Unfortunately, AIX/ksh doesn't recognize using {*} in csplit, so the max is {99}. Here's an example of the end of one invoice
*** ORDER COMPLETED *** 0.00
COST 69.76
^M
TOTAL AMT DUE TOTAL PROF PROF %^M
105.60 29.86 29.97^L
And this is the line I'm using to get the invoice number. The 1st slpit has this at line 20; from the re on it's line 19.
1179738-01 103 02/08/05 160 6380 02/11/05
I have to be able to keep the formatting exactly the same in the output file so it can be reprinted on the preprinted form if necessary. I was trying read the file line by line and cat/echo/etc to the output file, but they all seemed to left justify and remove spaces from each line.
Does anyone know of a way to get the same function as csplit w/o a limit?
Thanks
I have a large file that is a reprint of a bunch of invoices. I need to split the file into a seperate file for each invoice and then rename it using the invoice number from inside the file.
Here's what I have right now. I know it's not the prettiest...
csplit -s -k -finv -n4 /REPORTS/TEMPINV.TXT /PROF/+2 {99}
for FILE in $(ls inv*)
do
INV=$(head -20 $FILE| grep "[0-9][0-9]/[0-9][0-9]/[0-9][0-9]"|awk '{ pr
int $1 }')
mv $FILE "$INV".txt
done
Unfortunately, AIX/ksh doesn't recognize using {*} in csplit, so the max is {99}. Here's an example of the end of one invoice
*** ORDER COMPLETED *** 0.00
COST 69.76
^M
TOTAL AMT DUE TOTAL PROF PROF %^M
105.60 29.86 29.97^L
And this is the line I'm using to get the invoice number. The 1st slpit has this at line 20; from the re on it's line 19.
1179738-01 103 02/08/05 160 6380 02/11/05
I have to be able to keep the formatting exactly the same in the output file so it can be reprinted on the preprinted form if necessary. I was trying read the file line by line and cat/echo/etc to the output file, but they all seemed to left justify and remove spaces from each line.
Does anyone know of a way to get the same function as csplit w/o a limit?
Thanks