<?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: Shell program in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750223#M834626</link>
    <description>Hi, &lt;BR /&gt;&lt;BR /&gt;Typo in my quick draft of a script:&lt;BR /&gt;&lt;BR /&gt;lineno=`expr $lineno + ` &lt;BR /&gt;&lt;BR /&gt;should be:&lt;BR /&gt;&lt;BR /&gt;lineno=`expr $lineno + 1`&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards. &lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
    <pubDate>Sat, 22 Jun 2002 15:06:25 GMT</pubDate>
    <dc:creator>Steven Sim Kok Leong</dc:creator>
    <dc:date>2002-06-22T15:06:25Z</dc:date>
    <item>
      <title>Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750220#M834623</link>
      <description>Hi,&lt;BR /&gt;what I need to do is this.&lt;BR /&gt;1. Read a file called Mar28.csv, the file contains only two filed. For example,&lt;BR /&gt;Citi Bank Payment,-30&lt;BR /&gt;Deposit,1349.2&lt;BR /&gt;&lt;BR /&gt;2. If the second field contains a negative amount then I need to change it to&lt;BR /&gt;Citi Bank Payment,,-30&lt;BR /&gt;else if the second field is a positive number then I need to change it to&lt;BR /&gt;Deposit,1349.2,&lt;BR /&gt;I am trying to do this using shell programming.&lt;BR /&gt;I have been going round and round in circle for a while now without much success and if someone is kind enough to show it to me by giving an example I would really appreciate it.</description>
      <pubDate>Sat, 22 Jun 2002 14:41:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750220#M834623</guid>
      <dc:creator>Vande Matram</dc:creator>
      <dc:date>2002-06-22T14:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750221#M834624</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;To pick up the negative amount and add an extra , then:-&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat Mar28.csv | sed 's/,-/,,-/' &amp;gt;Mar28.csv-new&lt;BR /&gt;&lt;BR /&gt;This will change &lt;BR /&gt;&lt;BR /&gt;Citi Bank Payment,-30 &lt;BR /&gt;&lt;BR /&gt;to:-&lt;BR /&gt;&lt;BR /&gt;Citi Bank Payment,,-30 &lt;BR /&gt;&lt;BR /&gt;Can you attach and example of your cvs file?&lt;BR /&gt;&lt;BR /&gt;Paula&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 22 Jun 2002 14:59:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750221#M834624</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2002-06-22T14:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750222#M834625</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Off the top of my head, following is one most inefficent way which I typed in a rush (untested):&lt;BR /&gt;&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;&lt;BR /&gt;lineno=1&lt;BR /&gt;lastline=`wc -l $1|awk '{print $1}'`&lt;BR /&gt;&lt;BR /&gt;while [ "$lineno" -le "$lastline" ]&lt;BR /&gt;do&lt;BR /&gt;  line=`head -$lineno $1|tail -1`&lt;BR /&gt;  if echo $line|awk -F\, '{print $2}'|grep '\-' &amp;gt;/dev/null&lt;BR /&gt;  then&lt;BR /&gt;    echo $line|awk -F\, '{print $1,",,",$2}'&lt;BR /&gt;  else&lt;BR /&gt;    echo $line&lt;BR /&gt;  fi&lt;BR /&gt;  lineno=`expr $lineno + `&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.&lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Sat, 22 Jun 2002 15:03:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750222#M834625</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-06-22T15:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750223#M834626</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;Typo in my quick draft of a script:&lt;BR /&gt;&lt;BR /&gt;lineno=`expr $lineno + ` &lt;BR /&gt;&lt;BR /&gt;should be:&lt;BR /&gt;&lt;BR /&gt;lineno=`expr $lineno + 1`&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards. &lt;BR /&gt;&lt;BR /&gt;Steven Sim Kok Leong</description>
      <pubDate>Sat, 22 Jun 2002 15:06:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750223#M834626</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-06-22T15:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750224#M834627</link>
      <description>Probably the best tool for something like this is awk (or Perl). The attached bank.sh creates an awk script 'on the fly' and calls awk.&lt;BR /&gt;&lt;BR /&gt;bank.sh &amp;lt; Mar28.csv &amp;gt; Newfile&lt;BR /&gt;STAT=$?&lt;BR /&gt;&lt;BR /&gt;if ${STAT} is non-zero, bad input data was detected.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 22 Jun 2002 15:10:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750224#M834627</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-06-22T15:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750225#M834628</link>
      <description>awk 'BEGIN{FS=","} {printf "%s,",$1&lt;BR /&gt;        if ($2&amp;lt;0) printf ",%s\n",$2&lt;BR /&gt;        else printf "%s,\n",$2&lt;BR /&gt;}' INPUTFILE&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ceesjan</description>
      <pubDate>Sat, 22 Jun 2002 20:11:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750225#M834628</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-06-22T20:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750226#M834629</link>
      <description>Paula's sed is the most direct. However, If you wanted to use perl, then-&lt;BR /&gt;&lt;BR /&gt;perl -pie 's/[^,],-/,,-/' thefile.csv&lt;BR /&gt;&lt;BR /&gt;This will make the change and put the results back into the same file. The additional feature this has over Paula's is that if you forget and run the process twice on the same file, it will leave the file in the proper format. Paula's would just keep adding commas everytime is was run.&lt;BR /&gt;&lt;BR /&gt;perl... Try it.. You'll like it...&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;</description>
      <pubDate>Sat, 22 Jun 2002 22:52:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750226#M834629</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-06-22T22:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750227#M834630</link>
      <description>Hi guys! Thank you very much for all your help.&lt;BR /&gt;I appreciate your feedback very much, and so everyone gets 10 points. However, to be frank with you lot of the stuff you said, went over my head because I am just starting out learning UNIX. :-) However, I ended up using a much simpler approach using awk utility. It is so simple it is amazing :-) and makes me proud of myself!! You won't believe it but this one line did all the work for me!&lt;BR /&gt;awk -F',' '{if ($2 &amp;gt; 0) {print $2","} else {print ","$2}}' Mar28.csv&lt;BR /&gt;Are you surprised? Thanks guys...you all are awesome!</description>
      <pubDate>Mon, 24 Jun 2002 00:36:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750227#M834630</guid>
      <dc:creator>Vande Matram</dc:creator>
      <dc:date>2002-06-24T00:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750228#M834631</link>
      <description>It's too bad I can't assign myself 10 pts! ;-)</description>
      <pubDate>Mon, 24 Jun 2002 01:48:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750228#M834631</guid>
      <dc:creator>Vande Matram</dc:creator>
      <dc:date>2002-06-24T01:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Shell program</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750229#M834632</link>
      <description>Hi Vande,&lt;BR /&gt;Do you see any differences between your solution and mine? It's a good thing not to assign points to yourself.&lt;BR /&gt;Keep dreaming...</description>
      <pubDate>Mon, 24 Jun 2002 06:04:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-program/m-p/2750229#M834632</guid>
      <dc:creator>Ceesjan van Hattum</dc:creator>
      <dc:date>2002-06-24T06:04:12Z</dc:date>
    </item>
  </channel>
</rss>

