<?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: sed-append question in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869286#M98645</link>
    <description>My sed solution was based on the input file you had provided i.e&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;load /BC/TOC1&lt;BR /&gt;load /BC/TOC2&lt;BR /&gt;&lt;BR /&gt;description: testing&lt;BR /&gt;vob: bc&lt;BR /&gt;----------------------&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I am confused at &lt;BR /&gt;&amp;gt;/^load/,/^$/{&lt;BR /&gt;&amp;gt;/^$/{i\&lt;BR /&gt;&lt;BR /&gt;...it's a nested sed construct which applies commands at a particular address which is within the selected block. So the above command grabs all lines that start with the word load (^load) upto the first blank line (^$). Once it reaches the blank line it inserts the desired line above the blank one.&lt;BR /&gt;&lt;BR /&gt;hope it helps!</description>
    <pubDate>Wed, 27 Sep 2006 01:20:35 GMT</pubDate>
    <dc:creator>Sandman!</dc:creator>
    <dc:date>2006-09-27T01:20:35Z</dc:date>
    <item>
      <title>sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869270#M98629</link>
      <description>I have the following input&lt;BR /&gt;&lt;BR /&gt;load /BC/TOC1&lt;BR /&gt;load /BC/TOC2&lt;BR /&gt;&lt;BR /&gt;I want to add one more load after the last one, in this case: "load BC/TOC2"&lt;BR /&gt;&lt;BR /&gt;sed "/^load/a\load /BC/TOC3" $file&lt;BR /&gt;&lt;BR /&gt;it runs the sed twice :-( like the following&lt;BR /&gt;load /BC/TOC1&lt;BR /&gt;load /BC/TOC3&lt;BR /&gt;load /BC/TOC2&lt;BR /&gt;load /BC/TOC3&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;how do I change the sed statement to only append to the last one?&lt;BR /&gt;&lt;BR /&gt;the desired output will be &lt;BR /&gt;load /BC/TOC1&lt;BR /&gt;load /BC/TOC2&lt;BR /&gt;load /BC/TOC3&lt;BR /&gt;&lt;BR /&gt;thank you</description>
      <pubDate>Mon, 25 Sep 2006 15:25:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869270#M98629</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-09-25T15:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869271#M98630</link>
      <description>Alternative way is&lt;BR /&gt;echo " load/BC/TOC3" &amp;gt;&amp;gt; filename&lt;BR /&gt;&lt;BR /&gt;Abhijeet</description>
      <pubDate>Mon, 25 Sep 2006 15:39:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869271#M98630</guid>
      <dc:creator>Abhijeet_3</dc:creator>
      <dc:date>2006-09-25T15:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869272#M98631</link>
      <description>it will not work because I have other stuff in the file. I just show you guys the portion of the file that I want to modify.</description>
      <pubDate>Mon, 25 Sep 2006 15:42:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869272#M98631</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-09-25T15:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869273#M98632</link>
      <description>&lt;!--!*#--&gt;Hi Gemini:&lt;BR /&gt;&lt;BR /&gt;Try:&lt;BR /&gt;&lt;BR /&gt;# cat ./append&lt;BR /&gt;#!/usr/bin/sed -f&lt;BR /&gt;n&lt;BR /&gt;/^load TOC2/p&lt;BR /&gt;a\&lt;BR /&gt;load \/BC\/TOC3&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./append file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 25 Sep 2006 16:16:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869273#M98632</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-09-25T16:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869274#M98633</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Sorry, that should look like:&lt;BR /&gt;&lt;BR /&gt;# cat ./append&lt;BR /&gt;#!/usr/bin/sed -f&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sed -f&lt;BR /&gt;/^load \/BC\/TOC2/{&lt;BR /&gt;a\&lt;BR /&gt;load \/BC\/TOC3&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./append file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 25 Sep 2006 17:03:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869274#M98633</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-09-25T17:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869275#M98634</link>
      <description>sorry, I am still not making myself clear.&lt;BR /&gt;&lt;BR /&gt;the last entry may not always be /BC/TOC2, it can be /BC/TOC3, /BC/TOC4, the whole point is how to append the new entry just ONCE?&lt;BR /&gt;&lt;BR /&gt;thank you&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Sep 2006 17:53:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869275#M98634</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-09-25T17:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869276#M98635</link>
      <description>Hi Gemini:&lt;BR /&gt;&lt;BR /&gt;# cat ./append&lt;BR /&gt;#!/usr/bin/sed -f&lt;BR /&gt;${&lt;BR /&gt;a\&lt;BR /&gt;load \/BC\/TOC_&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;# ./append file&lt;BR /&gt;&lt;BR /&gt;...will append to the file's end.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Sep 2006 18:21:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869276#M98635</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-09-25T18:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869277#M98636</link>
      <description>are you sure?&lt;BR /&gt;&lt;BR /&gt;is the difference between yours and mine the "_"? I still get the same result :-(&lt;BR /&gt;&lt;BR /&gt;please help out...</description>
      <pubDate>Mon, 25 Sep 2006 19:17:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869277#M98636</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-09-25T19:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869278#M98637</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Well, mine works for me, so try this variation:&lt;BR /&gt;&lt;BR /&gt;# #!/usr/bin/sed -nf&lt;BR /&gt;p&lt;BR /&gt;${&lt;BR /&gt;a\&lt;BR /&gt;load \/BC\/TOC_&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;...substitute anything you want for "TOC_".&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 25 Sep 2006 19:29:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869278#M98637</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-09-25T19:29:53Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869279#M98638</link>
      <description>I don't think you can use sed at all.  Also, do you have more than one sequence of loads that can be present?  If so, you can't even use awk unless you make a grep -n prepass:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;FILE=itrc_append&lt;BR /&gt;&lt;BR /&gt;# fine last "load"&lt;BR /&gt;line=$(grep -n "^load" $FILE | tail -1 | sed 's/:.*$//')&lt;BR /&gt;&lt;BR /&gt;# add one "load /BC/TOC3" after the last "load".&lt;BR /&gt;sed -e "${line}a\\&lt;BR /&gt;load /BC/TOC3" $FILE</description>
      <pubDate>Mon, 25 Sep 2006 19:39:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869279#M98638</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-09-25T19:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869280#M98639</link>
      <description>okay....&lt;BR /&gt;&lt;BR /&gt;I should give a complete file to make my point clear&lt;BR /&gt;&lt;BR /&gt;the file is like&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;load /BC/TOC1&lt;BR /&gt;load /BC/TOC2&lt;BR /&gt;&lt;BR /&gt;description: testing&lt;BR /&gt;vob: bc&lt;BR /&gt;---------------------&lt;BR /&gt;&lt;BR /&gt;so, I can not just append at the end of the file..I need to append at the end of the load statement..&lt;BR /&gt;&lt;BR /&gt;the solutions above are all at the end of the file.....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Sep 2006 20:10:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869280#M98639</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-09-25T20:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869281#M98640</link>
      <description>&amp;gt;the solutions above are all at the end of the file.....&lt;BR /&gt;&lt;BR /&gt;Mine is not.  I find the LAST "load" and add after it.</description>
      <pubDate>Mon, 25 Sep 2006 20:36:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869281#M98640</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-09-25T20:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869282#M98641</link>
      <description>Try the sed command below. It inserts the line "load /BC/TOC3" right after the last load line in the input file.&lt;BR /&gt;&lt;BR /&gt;sed '&lt;BR /&gt;/^load/,/^$/{&lt;BR /&gt;/^$/{i\&lt;BR /&gt;load /BC/TOC3&lt;BR /&gt;}&lt;BR /&gt;}' infile&lt;BR /&gt;&lt;BR /&gt;~hope it helps</description>
      <pubDate>Mon, 25 Sep 2006 20:57:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869282#M98641</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-09-25T20:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869283#M98642</link>
      <description>Sandman's seems to work only if there is a blank line after the load.  Mine works no matter how many blocks of "load"s or what follows them.</description>
      <pubDate>Mon, 25 Sep 2006 21:25:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869283#M98642</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-09-25T21:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869284#M98643</link>
      <description>Thanks for Dennis Handly's solution. that works very well.&lt;BR /&gt;&lt;BR /&gt;I also like Sandman's solution, but I have question about your synatx&lt;BR /&gt;&lt;BR /&gt;sed '&lt;BR /&gt;/^load/,/^$/{&lt;BR /&gt;/^$/{i\&lt;BR /&gt;load /BC/TOC3&lt;BR /&gt;}&lt;BR /&gt;}' infile&lt;BR /&gt;&lt;BR /&gt;1.what does the first/second line mean?&lt;BR /&gt;&lt;BR /&gt;I am confused at &lt;BR /&gt;/^load/,/^$/{&lt;BR /&gt;/^$/{i\&lt;BR /&gt;&lt;BR /&gt;that is a new synatax to me..&lt;BR /&gt;&lt;BR /&gt;please kindly shed some light..&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Sep 2006 19:26:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869284#M98643</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2006-09-26T19:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869285#M98644</link>
      <description>&amp;gt;1.what does the first/second line mean?&lt;BR /&gt;&lt;BR /&gt;Basically for all lines from the first "load" to a blank line, do the {} block.  Inside the block it tests to make sure it is on the blank line and if so, insert.</description>
      <pubDate>Tue, 26 Sep 2006 20:13:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869285#M98644</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2006-09-26T20:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: sed-append question</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869286#M98645</link>
      <description>My sed solution was based on the input file you had provided i.e&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;load /BC/TOC1&lt;BR /&gt;load /BC/TOC2&lt;BR /&gt;&lt;BR /&gt;description: testing&lt;BR /&gt;vob: bc&lt;BR /&gt;----------------------&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I am confused at &lt;BR /&gt;&amp;gt;/^load/,/^$/{&lt;BR /&gt;&amp;gt;/^$/{i\&lt;BR /&gt;&lt;BR /&gt;...it's a nested sed construct which applies commands at a particular address which is within the selected block. So the above command grabs all lines that start with the word load (^load) upto the first blank line (^$). Once it reaches the blank line it inserts the desired line above the blank one.&lt;BR /&gt;&lt;BR /&gt;hope it helps!</description>
      <pubDate>Wed, 27 Sep 2006 01:20:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-append-question/m-p/3869286#M98645</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-09-27T01:20:35Z</dc:date>
    </item>
  </channel>
</rss>

