* Summary - Help Corn Shell
@ 1998-07-29 15:49 dthun
0 siblings, 0 replies; only message in thread
From: dthun @ 1998-07-29 15:49 UTC (permalink / raw)
To: tru64-unix-managers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-07-29 15:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-07-29 15:49 Summary - Help Corn Shell dthun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox