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