Many thanks to John Hascall His awk solutions are posted below.
also thanks to:
Scott L. McCracken
Brian Hill
--------------------------------------------------------------Orig
Post-------------------------------------------------------------------
Any Korn Shell wizards out there I have a question for you.
I have two files that contain the following data:
file1
al220710000410000068
file 2
al18022200041|****|1998-07-26|*********************************************
*****
*********************************
In file1I have to increment the far right number each night.
In file2 I have to increment the date each night.
Is there a way to do this with a Korn Shell script?
---------------------------------------------------------------------------
---------------
Solution-------------------------------------------------------------
In file1I have to increment the far right number each night.
It is not clear to me what you mean exactly by 'the far right number'
(just the last digit? '8' or '0000068'?) Here I assume the latter:
awk '{n=substr($0,14);printf "%s%07.7d\n", substr($0,1,13),n+1}' \
< file1 >file1.new
}In file2 I have to increment the date each night.
I am assuming by 'increment the date' you mean insert today's date:
awk '{printf "%s%s%s\n",substr($0,1,19),"'`date
+%Y-%m-%d`'",substr($0,30)}' \
< file2 >file2.new
John
P.S. See
http://www.oreilly.com/catalog/sed2/ for a fine book
on sed & awk
Received on Wed Jul 29 1998 - 15:48:59 NZST