<?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: hp textfile adding index in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743341#M786922</link>
    <description>hi,&lt;BR /&gt;using awk only (not cat is needed):&lt;BR /&gt;&lt;BR /&gt;read b?"Start index "&lt;BR /&gt;awk 'BEGIN {B='''$b'''};{print $0  " " B++}' file&lt;BR /&gt;&lt;BR /&gt;code in the BEGIN step assign to the AWK var B teh value of UNIX var b.&lt;BR /&gt;Rest of te code print the record in teh file plus the counter.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
    <pubDate>Mon, 06 Mar 2006 04:23:57 GMT</pubDate>
    <dc:creator>Arturo Galbiati</dc:creator>
    <dc:date>2006-03-06T04:23:57Z</dc:date>
    <item>
      <title>hp textfile adding index</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743335#M786916</link>
      <description>Hi Everyone,&lt;BR /&gt;&lt;BR /&gt;Can you help me here.&lt;BR /&gt;I have a file having contents below&lt;BR /&gt;asdf&lt;BR /&gt;qwer&lt;BR /&gt;asff&lt;BR /&gt;and i want to add an index prompting what control number will I start so if i say 1 it will change output to&lt;BR /&gt;&lt;BR /&gt;asdf 1&lt;BR /&gt;qwer 2&lt;BR /&gt;asff 3&lt;BR /&gt;&lt;BR /&gt;so if i say start number is 125 it will have output like&lt;BR /&gt;&lt;BR /&gt;asdf 125&lt;BR /&gt;qwer 126&lt;BR /&gt;asff 127&lt;BR /&gt;&lt;BR /&gt;so that it automatically increases by one for each entry. I will be glad if you can help me using this with awk. thanks much.</description>
      <pubDate>Fri, 03 Mar 2006 02:16:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743335#M786916</guid>
      <dc:creator>Ferdi Castro</dc:creator>
      <dc:date>2006-03-03T02:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: hp textfile adding index</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743336#M786917</link>
      <description>Hi Ferdi,&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;&lt;BR /&gt;cat file.text |awk '{print $1 "   "  a+1; a++}'&lt;BR /&gt;asf   1&lt;BR /&gt;bfc   2&lt;BR /&gt;edr   3&lt;BR /&gt;wes   4&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat file.text |awk '{print $1 "   "  a+120; a++}'&lt;BR /&gt;&lt;BR /&gt;asf   120&lt;BR /&gt;bfc   121&lt;BR /&gt;edr   122&lt;BR /&gt;wes   123&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Indira A</description>
      <pubDate>Fri, 03 Mar 2006 02:41:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743336#M786917</guid>
      <dc:creator>Indira Aramandla</dc:creator>
      <dc:date>2006-03-03T02:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: hp textfile adding index</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743337#M786918</link>
      <description>With awk would be nice,&lt;BR /&gt;but a quick solution would be something like this:&lt;BR /&gt;&lt;BR /&gt;#/sbin/sh&lt;BR /&gt;# script with passing parameter&lt;BR /&gt;typeset -i VAR&lt;BR /&gt;VAR=$1&lt;BR /&gt;cat yourfile |while read LINE&lt;BR /&gt;do&lt;BR /&gt;print "$LINE $VAR"&lt;BR /&gt;VAR=(($VAR + 1))&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;For a prompt you can add a read VAR&lt;BR /&gt;&lt;BR /&gt;#/sbin/sh&lt;BR /&gt;# script with prompt&lt;BR /&gt;&lt;BR /&gt;print "Type your control nr. here:\n"&lt;BR /&gt;typeset -i VAR&lt;BR /&gt;read VAR&lt;BR /&gt;&lt;BR /&gt;cat yourfile |while read LINE&lt;BR /&gt;do&lt;BR /&gt;print "$LINE $VAR"&lt;BR /&gt;VAR=(($VAR + 1))&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Many variations are possible,&lt;BR /&gt;but is the basic skeleton.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Mar 2006 02:44:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743337#M786918</guid>
      <dc:creator>Frank de Vries</dc:creator>
      <dc:date>2006-03-03T02:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: hp textfile adding index</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743338#M786919</link>
      <description>Thanks Indira. I find your solution better however I need it it to be prompted in a script&lt;BR /&gt;I tried ff same but it give me error?&lt;BR /&gt;&lt;BR /&gt;echo "enter start index \c"&lt;BR /&gt;read index&lt;BR /&gt;&lt;BR /&gt;cat file | awk '{print $1 | $index+1;$index++}'&lt;BR /&gt;&lt;BR /&gt;returns an error&lt;BR /&gt;&lt;BR /&gt;awk: Field $() is not correct.&lt;BR /&gt; The input line number is 1.&lt;BR /&gt; The source line number is 1.&lt;BR /&gt;&lt;BR /&gt;pls help&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;gives an error. Im pretty sure Im close its just that I need to get the clear use of variable.</description>
      <pubDate>Fri, 03 Mar 2006 03:00:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743338#M786919</guid>
      <dc:creator>Ferdi Castro</dc:creator>
      <dc:date>2006-03-03T03:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: hp textfile adding index</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743339#M786920</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;echo "enter start index \c"&lt;BR /&gt;read index&lt;BR /&gt;cat $file |awk -v a=$index '{print $1 " " a; a++}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;                Steve Steel</description>
      <pubDate>Fri, 03 Mar 2006 04:08:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743339#M786920</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2006-03-03T04:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: hp textfile adding index</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743340#M786921</link>
      <description>Hi Ferdi,&lt;BR /&gt;&lt;BR /&gt;awk dies not understand the $varibale as it is form the shell. May be use awk -v&lt;BR /&gt;&lt;BR /&gt;I think if you need to be prompted for the index number then do as a script.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;IA&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Mar 2006 04:08:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743340#M786921</guid>
      <dc:creator>Indira Aramandla</dc:creator>
      <dc:date>2006-03-03T04:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: hp textfile adding index</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743341#M786922</link>
      <description>hi,&lt;BR /&gt;using awk only (not cat is needed):&lt;BR /&gt;&lt;BR /&gt;read b?"Start index "&lt;BR /&gt;awk 'BEGIN {B='''$b'''};{print $0  " " B++}' file&lt;BR /&gt;&lt;BR /&gt;code in the BEGIN step assign to the AWK var B teh value of UNIX var b.&lt;BR /&gt;Rest of te code print the record in teh file plus the counter.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Mon, 06 Mar 2006 04:23:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hp-textfile-adding-index/m-p/3743341#M786922</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-03-06T04:23:57Z</dc:date>
    </item>
  </channel>
</rss>

