Hello Ann:<br><br>I'm assuming that the data file is "clean" i.e. NO extraneous lines (i.e. blank, non-printables, etc)<br><br>Use a printf statement as follows:<br><br>    printf "File No: CGA%03d\n",NR
<br><br>A little explanation is in order with this one.  The "0" (zero) after the % sign indicates a zero pading.<br>The 3 indicates the "size" of the numeric pad.  The "d" indicated numeric integer.  The "\n" is newline.
<br>The NR is an awk system variable for the current "record number."  Thus my stipulation before<br>about the other "stuff" in the file, i.e. blank lines, non-printables, lines before and after the textual body, etc
<br><br>Hope this helps.<br><br>Regards,<br>Lou<br>P.S. Awk!  Awk!  Awk!  (that's supposed to be laughter)  <br><br><div class="gmail_quote">On Nov 22, 2007 1:20 PM, ann kok <<a href="mailto:annkok2001@yahoo.com">annkok2001@yahoo.com
</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thank you again<br><br>here is expectation output<br><br>eg:<br><br>awk -v DT=`date +%Y%m%d` 
program.awk record.txt<br><br>The result is<br><br><br>File No: CGA001<br>Name: AAA<br>Country: USA<br>Created: 20071122<br>Updated: 20071122<br><br><br>File No: CGA002<br>Name: BBB<br>Country: Australia<br>Created: 20071122
<br>Updated: 20071122<br><br><br>File No: CGA003<br>Name: CCC<br>Country: England<br>Created: 20071122<br>Updated: 20071122<br><br><br>The program is program.awk<br><br>     BEGIN { RS = "\n" ; FS = "|" }
<br><br>     {<br>           print "File No:", CGAxxx <=== how to<br>change?<br>           print "Name:", $1<br>           print "Country:", $2<br>           printf "Created: %s\n", DT
<br>           printf "Updated: %s\n", DT<br>           print ""<br>     }<br><br><br>the record.txt is<br><br>AAA|USA<br>BBB|Australia<br>CCC|England<br><br><br>Thank you<br><div><div></div><div class="Wj3C7c">
<br><br><br><br><br><br>--- Lou Spironello <<a href="mailto:lspironello@gmail.com">lspironello@gmail.com</a>> wrote:<br><br>> Hello Ann:<br>><br>> man (g)awk<br>><br>> :-)<br>><br>> awk -v | --assign  <internal variable
<br>> name>=<variable value> <other awk<br>> options and stuff><br>><br>><br>> Not quite sure what you want to do do.  Can you show<br>> the resulting output or<br>> be a bit more specific.
<br>><br>><br>> Regards,<br>> Lou<br>> On Nov 22, 2007 12:55 PM, ann kok<br>> <<a href="mailto:annkok2001@yahoo.com">annkok2001@yahoo.com</a>> wrote:<br>><br>> > Hi Lou<br>> ><br>> > Thank you very much
<br>> ><br>> > One more question. how can I put the CGA number as<br>> > variable?<br>> ><br>> > eg: CGA001, CGA002..... when<br>> > i run the program<br>> ><br>> > awk -v CGA=`for loop` 
program.awk file.txt<br>> ><br>> > or any way to do it?<br>> ><br>> > Thank you again<br>> ><br>> ><br>> ><br>> > BEGIN { RS = "\n" ; FS = "|" }<br>> > {
<br>> > print "File No.: CGA001<br>> > print ""<br>> > }<br>> ><br>> ><br>> > --- Lou Spironello <<a href="mailto:lspironello@gmail.com">lspironello@gmail.com</a>> wrote:
<br>> ><br>> > > awk -v HST=`hostname` -f program.awk file.txt<br>> > ><br>> > > inside program.awk<br>> > > use:<br>> > ><br>> > >   printf "from: %s\n",HST
<br>> > ><br>> > > Regards,<br>> > > Lou<br>> > ><br>> > > On Nov 21, 2007 3:41 PM, ann kok<br>> > > <<a href="mailto:annkok2001@yahoo.com">annkok2001@yahoo.com</a>
> wrote:<br>> > ><br>> > > > Thank you<br>> > > ><br>> > > > but i don't know how to put the hostname in<br>> awk<br>> > > > program<br>> > > >
<br>> > > > eg: my program is "program.awk<br>> > > ><br>> > > > awk -f program.awk file.txt<br>> > > ><br>> > > > Thank you again<br>> > > ><br>
> > > > BEGIN { RS = "\n" ; FS = "|" }<br>> > > ><br>> > > >  {<br>> > > > print "Name:", $9<br>> > > > print "Created: `date`"
<br>> > > > print "from: `hostname`"<br>> > > > print ""<br>> > > > }<br>> > > ><br>> > > ><br>> > > > --- Lou Spironello <<a href="mailto:lspironello@gmail.com">
lspironello@gmail.com</a>><br>> wrote:<br>> > > ><br>> > > > > Hope this helps.<br>> > > > ><br>> > > > > echo "test" | awk -v mydate=`date +%Y%m%d`
<br>> > > '{printf<br>> > > > > "standard input is<br>> > > > > %s\nmy variable value is %s\n",$1,mydate}'<br>> > > > ><br>> > > > > :-)
<br>> > > > ><br>> > > > ><br>> > > > > Regards,<br>> > > > > Lou<br>> > > > ><br>> > > > > On Nov 21, 2007 12:22 PM, ann kok<br>> > > > > <
<a href="mailto:annkok2001@yahoo.com">annkok2001@yahoo.com</a>> wrote:<br>> > > > ><br>> > > > > > Hi all<br>> > > > > ><br>> > > > > > how can I print date in this date format?
<br>> > > 20071122<br>> > > > > ><br>> > > > > > Can command "date, hostname" run in awk<br>> > > program<br>> > > > > > itself?<br>> > > > > >
<br>> > > > > > program.awk<br>> > > > > ><br>> > > > > >     BEGIN { RS = "\n" ; FS = "|" }<br>> > > > > ><br>> > > > > >     {
<br>> > > > > >           print "Name:", $9<br>> > > > > >           print "Created: `date`"<br>> > > > > >           print "from: `hostname`"
<br>> > > > > >           print ""<br>> > > > > >     }<br>> > > > > ><br>> > > > > > Thank you<br>> > > > > ><br>> > > > > >
<br>> > > > > ><br>> > > > > ><br>> > > > ><br>> > > ><br>> > > ><br>> > ><br>> ><br>> ><br>><br>____________________________________________________________________________________
<br>> > > > > > Be a better pen pal.<br>> > > > > > Text or chat with friends inside Yahoo!<br>> Mail.<br>> > > See<br>> > > > > how.<br>> > > > > > 
<a href="http://overview.mail.yahoo.com/" target="_blank">http://overview.mail.yahoo.com/</a><br>> > > > > ><br>> > > > > > --<br>> > > > > > fedora-list mailing list<br>
> > > > > > <a href="mailto:fedora-list@redhat.com">fedora-list@redhat.com</a><br>> > > > > > To unsubscribe:<br>> > > > ><br>> > ><br>> <a href="https://www.redhat.com/mailman/listinfo/fedora-list" target="_blank">
https://www.redhat.com/mailman/listinfo/fedora-list</a><br>> > > > > ><br>> > > > > > --<br>> > > > > fedora-list mailing list<br>> > > > > <a href="mailto:fedora-list@redhat.com">
fedora-list@redhat.com</a><br>> > > > > To unsubscribe:<br>> > > ><br>> > ><br>> <a href="https://www.redhat.com/mailman/listinfo/fedora-list" target="_blank">https://www.redhat.com/mailman/listinfo/fedora-list
</a><br>> > > ><br>> > > ><br>> > > ><br>> > > ><br>> > > ><br>> > ><br>> ><br>> ><br>><br>____________________________________________________________________________________
<br>> > > > Get easy, one-click access to your favorites.<br>> > > > Make Yahoo! your homepage.<br>> > > > <a href="http://www.yahoo.com/r/hs" target="_blank">http://www.yahoo.com/r/hs</a>
<br>> > > ><br>> > > > --<br>> > > > fedora-list mailing list<br>> > > > <a href="mailto:fedora-list@redhat.com">fedora-list@redhat.com</a><br>> > > > To unsubscribe:
<br>> > ><br>> <a href="https://www.redhat.com/mailman/listinfo/fedora-list" target="_blank">https://www.redhat.com/mailman/listinfo/fedora-list</a><br>> > > ><br>> > > > --<br>> > > fedora-list mailing list
<br>> > > <a href="mailto:fedora-list@redhat.com">fedora-list@redhat.com</a><br>> > > To unsubscribe:<br>> ><br>> <a href="https://www.redhat.com/mailman/listinfo/fedora-list" target="_blank">https://www.redhat.com/mailman/listinfo/fedora-list
</a><br>> ><br>> ><br>> ><br>> ><br>> ><br>><br>____________________________________________________________________________________<br>> > Be a better pen pal.<br>> > Text or chat with friends inside Yahoo! Mail. See
<br>> how.<br>> > <a href="http://overview.mail.yahoo.com/" target="_blank">http://overview.mail.yahoo.com/</a><br>> ><br>> > --<br>> > fedora-list mailing list<br>> > <a href="mailto:fedora-list@redhat.com">
fedora-list@redhat.com</a><br>> > To unsubscribe:<br>> <a href="https://www.redhat.com/mailman/listinfo/fedora-list" target="_blank">https://www.redhat.com/mailman/listinfo/fedora-list</a><br>> ><br></div></div>
> > --<br><div><div></div><div class="Wj3C7c">> fedora-list mailing list<br>> <a href="mailto:fedora-list@redhat.com">fedora-list@redhat.com</a><br>> To unsubscribe:<br><a href="https://www.redhat.com/mailman/listinfo/fedora-list" target="_blank">
https://www.redhat.com/mailman/listinfo/fedora-list</a><br><br><br><br>      ____________________________________________________________________________________<br>Be a better pen pal.<br>Text or chat with friends inside Yahoo! Mail. See how.  
<a href="http://overview.mail.yahoo.com/" target="_blank">http://overview.mail.yahoo.com/</a><br><br>--<br>fedora-list mailing list<br><a href="mailto:fedora-list@redhat.com">fedora-list@redhat.com</a><br>To unsubscribe: 
<a href="https://www.redhat.com/mailman/listinfo/fedora-list" target="_blank">https://www.redhat.com/mailman/listinfo/fedora-list</a><br></div></div></blockquote></div><br>