<?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: script question: update fields in a txt file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763452#M259891</link>
    <description>don't want to create another temp file to achieve this.</description>
    <pubDate>Fri, 31 Mar 2006 14:27:15 GMT</pubDate>
    <dc:creator>yyghp</dc:creator>
    <dc:date>2006-03-31T14:27:15Z</dc:date>
    <item>
      <title>script question: update fields in a txt file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763451#M259890</link>
      <description>Hi there,&lt;BR /&gt;&lt;BR /&gt;I am going to scan a txt file every 5 minutes, and will update the column(s) in the file depends on the current situation.&lt;BR /&gt;For example:  itemprice.txt&lt;BR /&gt;&lt;BR /&gt;CPU          110&lt;BR /&gt;Memory       80&lt;BR /&gt;Vediocard    50&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;I need to update the numbers every time I scan this file.&lt;BR /&gt;How can I script this?&lt;BR /&gt;Thanks a lot!&lt;BR /&gt;&lt;BR /&gt;while read -r col1 col2&lt;BR /&gt;   do &lt;BR /&gt;       # read the price from database&lt;BR /&gt;       # want to update $col2, and write to the file, but how to do here?&lt;BR /&gt;&lt;BR /&gt;done &amp;lt; itemprice.txt</description>
      <pubDate>Fri, 31 Mar 2006 14:24:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763451#M259890</guid>
      <dc:creator>yyghp</dc:creator>
      <dc:date>2006-03-31T14:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: script question: update fields in a txt file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763452#M259891</link>
      <description>don't want to create another temp file to achieve this.</description>
      <pubDate>Fri, 31 Mar 2006 14:27:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763452#M259891</guid>
      <dc:creator>yyghp</dc:creator>
      <dc:date>2006-03-31T14:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: script question: update fields in a txt file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763453#M259892</link>
      <description>You really can't as described. Textfiles have varying record lengths so there is no way to simply update a line. Whay you do is rewrite the entire file as a temporary file then mv the temporary file to the original.&lt;BR /&gt;&lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset T1=${TDIR}/X${$}_1.tmp&lt;BR /&gt;&lt;BR /&gt;typeset INFILE=itemprice.txt&lt;BR /&gt;typeset col1=""&lt;BR /&gt;typeset col2=""&lt;BR /&gt;typeset NEWCOL2="xxx"&lt;BR /&gt;while read -r col1 col2&lt;BR /&gt;  do&lt;BR /&gt;     # do whatever to set ${NEWCOL2}&lt;BR /&gt;     echo "${col1} ${NEWCOL2}" &amp;gt;&amp;gt; ${T1}&lt;BR /&gt;  done &amp;lt; ${INFILE}&lt;BR /&gt;mv ${T1} ${INFILE}&lt;BR /&gt;&lt;BR /&gt;There are much more efficient ways to do this using perl, awk, or sed but you seemed to want a shell approach.     &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 31 Mar 2006 14:33:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763453#M259892</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-03-31T14:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: script question: update fields in a txt file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763454#M259893</link>
      <description>If it a specific list of items you want to update, then keep that list in a file without the price and read it in, example-&lt;BR /&gt; &lt;BR /&gt;exec &amp;gt;yourtextfile&lt;BR /&gt;for x `cat listofthings` ; do&lt;BR /&gt;newprice=`lookupdb $x`&lt;BR /&gt;echo $x $newprice&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Where-&lt;BR /&gt;- yourtextfile is where to put the results&lt;BR /&gt;- listofthings is just the col 1 items&lt;BR /&gt;- lookupdb is the program to look up price&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Fri, 31 Mar 2006 14:50:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763454#M259893</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-03-31T14:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: script question: update fields in a txt file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763455#M259894</link>
      <description>Hello&lt;BR /&gt;&lt;BR /&gt;It all depends on how you're reading the item prices from the database and how you're storing them? Whether you are using shell or database variables for storing the item prices read from the database? It will help if you could be specific.&lt;BR /&gt;&lt;BR /&gt;thanks!</description>
      <pubDate>Fri, 31 Mar 2006 14:59:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-question-update-fields-in-a-txt-file/m-p/3763455#M259894</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-03-31T14:59:06Z</dc:date>
    </item>
  </channel>
</rss>

