<?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: 3rd line of Script modification in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339742#M874564</link>
    <description>If I understand what you are asking, in the parent script use these lines of code:&lt;BR /&gt;&lt;BR /&gt;typeset -i LINENUM=3&lt;BR /&gt;typeset -i INCR=100&lt;BR /&gt;typeset CHSCR="childscript.sh"&lt;BR /&gt;typeset -i i=0&lt;BR /&gt;typeset -i x=0&lt;BR /&gt;&lt;BR /&gt;while read inline&lt;BR /&gt;do&lt;BR /&gt;[[ -n "$inline" || "$inline" = \#* ]] &amp;amp;&amp;amp; continue&lt;BR /&gt;line[$x]="$inline"&lt;BR /&gt;((x += 1))&lt;BR /&gt;done &amp;lt; $CHSCR&lt;BR /&gt;&lt;BR /&gt;# convert to a number&lt;BR /&gt;i="${line[$LINENUM]}"&lt;BR /&gt;((i+=INCR))&lt;BR /&gt;line[$LINENUM]="$i"&lt;BR /&gt;&lt;BR /&gt;i=${#line[*]}&lt;BR /&gt;x=0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while ((x &amp;lt; i ))&lt;BR /&gt;do&lt;BR /&gt;echo "${line[$x]}"&lt;BR /&gt;((x += 1))&lt;BR /&gt;done &amp;gt;$CHSCR&lt;BR /&gt;&lt;BR /&gt;=========================================&lt;BR /&gt;&lt;BR /&gt;I am assuming that your quotes (") in the example are not actually in the childscript.sh file.  If they are, you will need to change the "convert" code to:&lt;BR /&gt;&lt;BR /&gt;i="${line[$LINENUM]%\"}"&lt;BR /&gt;((i+=INCR))&lt;BR /&gt;line[$LINENUM]="$i"\"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sat, 24 Jul 2004 13:40:32 GMT</pubDate>
    <dc:creator>Dan Martin_1</dc:creator>
    <dc:date>2004-07-24T13:40:32Z</dc:date>
    <item>
      <title>3rd line of Script modification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339737#M874559</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I need to change the third line of the script such as ...&lt;BR /&gt;&lt;BR /&gt;for instance : 3rd line value is 250, &lt;BR /&gt;I need to update the record by 350 and so forth ..&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Jul 2004 08:10:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339737#M874559</guid>
      <dc:creator>la_cool</dc:creator>
      <dc:date>2004-07-23T08:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: 3rd line of Script modification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339738#M874560</link>
      <description>&lt;BR /&gt;use vi ??&lt;BR /&gt;&lt;BR /&gt;Are you saying that you have a script or that you need to write one, that will change the value in some file on line 3 from the value 250 to 350 ?? &lt;BR /&gt;&lt;BR /&gt;If you are changing a file(s), then are these files text type files?&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Fri, 23 Jul 2004 08:25:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339738#M874560</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-07-23T08:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: 3rd line of Script modification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339739#M874561</link>
      <description>If you want to replace "250" in the third line in of a file to "350", either use vi or&lt;BR /&gt;use this simple awk script,&lt;BR /&gt;-----250.awk---&lt;BR /&gt;BEGIN {&lt;BR /&gt;FS="\n"&lt;BR /&gt;OFS="\n"&lt;BR /&gt;RS=""&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;gsub ("250","350", $3)&lt;BR /&gt;print $0&lt;BR /&gt;}&lt;BR /&gt;---------&lt;BR /&gt;&lt;BR /&gt;#awk -f 250.awk myfile&lt;BR /&gt;&lt;BR /&gt;regds,&lt;BR /&gt;Abdul.&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Jul 2004 09:05:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339739#M874561</guid>
      <dc:creator>Abdul Rahiman</dc:creator>
      <dc:date>2004-07-23T09:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: 3rd line of Script modification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339740#M874562</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I think I was not clear enough .. let me elaborate more in detail ..&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I have a master script, that would actually change the content of the sub script(2 file) dynamically, and content of the sub script would be something like this &lt;BR /&gt;&lt;BR /&gt;When I run the Parentscript.sh &lt;BR /&gt;&lt;BR /&gt;child script content will be something like this (childscript.sh)&lt;BR /&gt;&lt;BR /&gt;Content has  3 lines in the script &lt;BR /&gt;&lt;BR /&gt;"125,435&lt;BR /&gt;121,test&lt;BR /&gt;450"&lt;BR /&gt;&lt;BR /&gt;The value 450(+100) will be changed dynamically to 550 when I run the master script and again I run the master script, the value will be changed  to 650 and so forth .. (&lt;BR /&gt;&lt;BR /&gt;In short: &lt;BR /&gt;Childscript.sh  - Value should be changed dynamically to +100 everytime When I run the master script ........&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 23 Jul 2004 09:32:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339740#M874562</guid>
      <dc:creator>la_cool</dc:creator>
      <dc:date>2004-07-23T09:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: 3rd line of Script modification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339741#M874563</link>
      <description>in one file you can change it vi editor&lt;BR /&gt;&lt;BR /&gt;vi file&lt;BR /&gt;&lt;BR /&gt;:/%s/250/350/ enter&lt;BR /&gt;&lt;BR /&gt;:x  #save and quit&lt;BR /&gt;&lt;BR /&gt;if you want  script, simply like this:&lt;BR /&gt;&lt;BR /&gt;#!/bin/bash&lt;BR /&gt;&lt;BR /&gt;sed 's/250/350/' file.txt &amp;gt; changed_file.txt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;br Jan</description>
      <pubDate>Fri, 23 Jul 2004 10:09:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339741#M874563</guid>
      <dc:creator>Jan Sladky</dc:creator>
      <dc:date>2004-07-23T10:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: 3rd line of Script modification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339742#M874564</link>
      <description>If I understand what you are asking, in the parent script use these lines of code:&lt;BR /&gt;&lt;BR /&gt;typeset -i LINENUM=3&lt;BR /&gt;typeset -i INCR=100&lt;BR /&gt;typeset CHSCR="childscript.sh"&lt;BR /&gt;typeset -i i=0&lt;BR /&gt;typeset -i x=0&lt;BR /&gt;&lt;BR /&gt;while read inline&lt;BR /&gt;do&lt;BR /&gt;[[ -n "$inline" || "$inline" = \#* ]] &amp;amp;&amp;amp; continue&lt;BR /&gt;line[$x]="$inline"&lt;BR /&gt;((x += 1))&lt;BR /&gt;done &amp;lt; $CHSCR&lt;BR /&gt;&lt;BR /&gt;# convert to a number&lt;BR /&gt;i="${line[$LINENUM]}"&lt;BR /&gt;((i+=INCR))&lt;BR /&gt;line[$LINENUM]="$i"&lt;BR /&gt;&lt;BR /&gt;i=${#line[*]}&lt;BR /&gt;x=0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while ((x &amp;lt; i ))&lt;BR /&gt;do&lt;BR /&gt;echo "${line[$x]}"&lt;BR /&gt;((x += 1))&lt;BR /&gt;done &amp;gt;$CHSCR&lt;BR /&gt;&lt;BR /&gt;=========================================&lt;BR /&gt;&lt;BR /&gt;I am assuming that your quotes (") in the example are not actually in the childscript.sh file.  If they are, you will need to change the "convert" code to:&lt;BR /&gt;&lt;BR /&gt;i="${line[$LINENUM]%\"}"&lt;BR /&gt;((i+=INCR))&lt;BR /&gt;line[$LINENUM]="$i"\"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 24 Jul 2004 13:40:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339742#M874564</guid>
      <dc:creator>Dan Martin_1</dc:creator>
      <dc:date>2004-07-24T13:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: 3rd line of Script modification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339743#M874565</link>
      <description>f1=yourfile&lt;BR /&gt;tmpfile=/tmp/something$$&lt;BR /&gt;&lt;BR /&gt;awk '&lt;BR /&gt;NR == 3 {&lt;BR /&gt;x=$1+0;&lt;BR /&gt;x+=100;&lt;BR /&gt;$1=x;&lt;BR /&gt;print $0;&lt;BR /&gt;next;&lt;BR /&gt;}&lt;BR /&gt;{print;}' $f1 &amp;gt; $tmpfile&lt;BR /&gt;&lt;BR /&gt;if [ $? = 0 ] ;then&lt;BR /&gt;mv $tmpfile $f1&lt;BR /&gt;else&lt;BR /&gt;print "awk error"&lt;BR /&gt;fi</description>
      <pubDate>Sat, 24 Jul 2004 17:21:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/3rd-line-of-script-modification/m-p/3339743#M874565</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-07-24T17:21:35Z</dc:date>
    </item>
  </channel>
</rss>

