<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need help  for scripting.. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124053#M802602</link>
    <description>once you have the record count, you can format it with awk:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RECORD_COUNT= `echo $RECORDS| awk ' { printf "%06d", $1 }'`&lt;BR /&gt;&lt;BR /&gt;where $RECORDS is the unformatted count, and RECORD_COUNT would be the formatted number. So if $RECORDS = 589, $RECORD_COUNT would be 000589.&lt;BR /&gt;&lt;BR /&gt;mark</description>
    <pubDate>Wed, 19 Nov 2003 15:53:46 GMT</pubDate>
    <dc:creator>Mark Greene_1</dc:creator>
    <dc:date>2003-11-19T15:53:46Z</dc:date>
    <item>
      <title>Need help  for scripting..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124048#M802597</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I would need to add a trailer record into a file generated by a script. The trailer record format should be "TRAILERDDMMYYYYNNNNNN"&lt;BR /&gt;where DD=current date, MM=current Month, YYYY=current year and NNNNNN=no of records in the file (excluding the trailor record).&lt;BR /&gt;&lt;BR /&gt;For example, for a file created on November 17, 2003 with 645 records, the trailor should read as  TRAILER17112003000645&lt;BR /&gt;&lt;BR /&gt;Now, As you see in the example, the number of records could be any thing from 1 to 999999.&lt;BR /&gt;&lt;BR /&gt;What should I do to create the trailor record in the proper format to fill all the 6 record fields. i.e, if the number of record is 589, then it should read as 000589 &lt;BR /&gt;&lt;BR /&gt;Appreciate your help!&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sailesh</description>
      <pubDate>Wed, 19 Nov 2003 15:26:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124048#M802597</guid>
      <dc:creator>Sailesh_1</dc:creator>
      <dc:date>2003-11-19T15:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help  for scripting..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124049#M802598</link>
      <description>seqid=`date -u +%d%m%Y`&lt;BR /&gt;filename=TRAILER$seqid&lt;BR /&gt;I don't know what you meen with records. Could you please clarify!</description>
      <pubDate>Wed, 19 Nov 2003 15:39:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124049#M802598</guid>
      <dc:creator>Jannik</dc:creator>
      <dc:date>2003-11-19T15:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need help  for scripting..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124050#M802599</link>
      <description>You may find the following date converstion script useful in your scriptng.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.hpux.ws/merijn/caljd.sh" target="_blank"&gt;http://www.hpux.ws/merijn/caljd.sh&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;A. Clay Stephenson Wrote it.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 19 Nov 2003 15:43:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124050#M802599</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-11-19T15:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help  for scripting..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124051#M802600</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Something like this might work.  I wrote a little shell script named trail.sh.  Just pass it the filename to generate the trailer record for as a parameter.  The 'somefile' I used has ten lines in it:&lt;BR /&gt;&lt;BR /&gt;&amp;gt;cat trail.sh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;# trail.sh&lt;BR /&gt;&lt;BR /&gt;MYFILE=$1&lt;BR /&gt;typeset -Z6 LINES&lt;BR /&gt;MYLINES=$(wc -l $MYFILE | awk '{print $1}')&lt;BR /&gt;MYDATE=$(date '+%d%m%Y')&lt;BR /&gt;&lt;BR /&gt;echo "TRAILER${MYDATE}${MYLINES}"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;./trail.sh somefile&lt;BR /&gt;TRAILER19112003000010&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The trick to formatting your record count is to use the 'typeset' command.  The -Z6 option tells typeset that the MYLINES variable will be six numeric characters, zero filled.  You can read up on typeset in the sh-posix man page.&lt;BR /&gt;&lt;BR /&gt;Have fun!&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Nov 2003 15:50:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124051#M802600</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-11-19T15:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need help  for scripting..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124052#M802601</link>
      <description>Thanks for the reply.&lt;BR /&gt;Records are something like the number of entries in the file. simply &lt;BR /&gt;&lt;BR /&gt;$ cat file_name |wc -l&lt;BR /&gt;&lt;BR /&gt;There are 6 feilds allotted for the records.&lt;BR /&gt;and I need to fill all the six fields.even if the number is 589, the trailor should looks like TRAILOR`date`000589. My question is how do I add those zeros in it?&lt;BR /&gt;&lt;BR /&gt;i.e, if the record is 589, then i need to add 3 zeros before 589. and if the record is 1589. then i need to add 2 zeros before 1589 to fill the vacant. &lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sailesh</description>
      <pubDate>Wed, 19 Nov 2003 15:50:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124052#M802601</guid>
      <dc:creator>Sailesh_1</dc:creator>
      <dc:date>2003-11-19T15:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help  for scripting..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124053#M802602</link>
      <description>once you have the record count, you can format it with awk:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RECORD_COUNT= `echo $RECORDS| awk ' { printf "%06d", $1 }'`&lt;BR /&gt;&lt;BR /&gt;where $RECORDS is the unformatted count, and RECORD_COUNT would be the formatted number. So if $RECORDS = 589, $RECORD_COUNT would be 000589.&lt;BR /&gt;&lt;BR /&gt;mark</description>
      <pubDate>Wed, 19 Nov 2003 15:53:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124053#M802602</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2003-11-19T15:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need help  for scripting..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124054#M802603</link>
      <description>Hi,&lt;BR /&gt;the easiest way is to make use of the korn shell's capacities, e.g. try this example:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset -Z6 NUMBER&lt;BR /&gt;NUMBER=$(wc -l ./infile|awk '{print $1}')&lt;BR /&gt;echo $NUMBER&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;for further information, man ksh and look for typeset.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Wed, 19 Nov 2003 16:01:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124054#M802603</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-11-19T16:01:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help  for scripting..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124055#M802604</link>
      <description>Thank you Mark and all others who replied.&lt;BR /&gt;That works perfect!!&lt;BR /&gt;&lt;BR /&gt;Thank you all once again.&lt;BR /&gt;&lt;BR /&gt;Sailesh</description>
      <pubDate>Wed, 19 Nov 2003 16:11:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-help-for-scripting/m-p/3124055#M802604</guid>
      <dc:creator>Sailesh_1</dc:creator>
      <dc:date>2003-11-19T16:11:33Z</dc:date>
    </item>
  </channel>
</rss>

