<?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: add new string using sed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176499#M794085</link>
    <description>Since you are insisting on using sed :-)),&lt;BR /&gt;&lt;BR /&gt;#echo &amp;gt;&amp;gt; hello.txt&lt;BR /&gt;&lt;BR /&gt;#sed /^$/s/^$/"$x"/g hello.txt&lt;BR /&gt;HELLO LINUX&lt;BR /&gt;HELLO WINDOWS&lt;BR /&gt;HELLO UNIX&lt;BR /&gt;&lt;BR /&gt;However here I assume that there are no blank lines else where in this file than the end of file.&lt;BR /&gt;&lt;BR /&gt;-Karthik S S</description>
    <pubDate>Thu, 29 Jan 2004 05:52:18 GMT</pubDate>
    <dc:creator>Karthik S S</dc:creator>
    <dc:date>2004-01-29T05:52:18Z</dc:date>
    <item>
      <title>add new string using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176494#M794080</link>
      <description>Hi all.&lt;BR /&gt;&lt;BR /&gt;I have a shell variable $x.&lt;BR /&gt;&lt;BR /&gt;# echo $x&lt;BR /&gt;HELLO UNIX&lt;BR /&gt;&lt;BR /&gt;I also have an ASCII file hello.txt.&lt;BR /&gt;&lt;BR /&gt;#cat hello.txt&lt;BR /&gt;HELLO LINUX&lt;BR /&gt;HELLO WINDOWS&lt;BR /&gt;&lt;BR /&gt;How can I add a value of the shell variable $x to the end of my file using sed?&lt;BR /&gt;&lt;BR /&gt;"cat $x &amp;gt;&amp;gt; hello.txt" is not useful to me. &lt;BR /&gt;&lt;BR /&gt;Your help with SED statement is appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Sergejs</description>
      <pubDate>Wed, 28 Jan 2004 10:59:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176494#M794080</guid>
      <dc:creator>Sergejs Svitnevs</dc:creator>
      <dc:date>2004-01-28T10:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: add new string using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176495#M794081</link>
      <description>This is pointless to do with sed -- although it can be done. You should realize that sed can never edit a file directly; it creates a new file. Often a temp file is created based upon the input file and then the temp file is mv'ed to the input file.&lt;BR /&gt;&lt;BR /&gt;This will worl just fine and will do the job with the file in place:&lt;BR /&gt;echo "${x}" &amp;gt;&amp;gt; hello.txt&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Jan 2004 11:03:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176495#M794081</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2004-01-28T11:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: add new string using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176496#M794082</link>
      <description>Sergejs --&lt;BR /&gt;&lt;BR /&gt;Perhaps you could tell us more about the application that you want to use this in or explain why you want to use sed to do this operation ?&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Jan 2004 12:31:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176496#M794082</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2004-01-28T12:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: add new string using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176497#M794083</link>
      <description>Hi Segejs,&lt;BR /&gt;&lt;BR /&gt;You will need to use 'echo' instead of "cat" to print $x into hello.txt. &lt;BR /&gt;&lt;BR /&gt;echo "$x" &amp;gt;&amp;gt; hello.txt&lt;BR /&gt;&lt;BR /&gt;If you insist of sed, below is the way&lt;BR /&gt;&lt;BR /&gt;sed 's/$/'"$x"'/' hello.txt &amp;gt; 1&lt;BR /&gt;mv 1 hello.txt&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Wed, 28 Jan 2004 12:39:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176497#M794083</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2004-01-28T12:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: add new string using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176498#M794084</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;It's better to do that with ex :&lt;BR /&gt;&lt;BR /&gt;#ex -s FILE  &amp;lt;&amp;lt; EOF&lt;BR /&gt;&amp;gt;                /^TOTO/&lt;BR /&gt;&amp;gt;                s/TOTO/TOTO2/&lt;BR /&gt;&amp;gt;                w&lt;BR /&gt;&amp;gt; EOF&lt;BR /&gt;&lt;BR /&gt;TOTO=variable&lt;BR /&gt;TOTO2=new variable&lt;BR /&gt;&lt;BR /&gt;Best regards</description>
      <pubDate>Thu, 29 Jan 2004 05:30:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176498#M794084</guid>
      <dc:creator>Aupee Jean-Francois</dc:creator>
      <dc:date>2004-01-29T05:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: add new string using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176499#M794085</link>
      <description>Since you are insisting on using sed :-)),&lt;BR /&gt;&lt;BR /&gt;#echo &amp;gt;&amp;gt; hello.txt&lt;BR /&gt;&lt;BR /&gt;#sed /^$/s/^$/"$x"/g hello.txt&lt;BR /&gt;HELLO LINUX&lt;BR /&gt;HELLO WINDOWS&lt;BR /&gt;HELLO UNIX&lt;BR /&gt;&lt;BR /&gt;However here I assume that there are no blank lines else where in this file than the end of file.&lt;BR /&gt;&lt;BR /&gt;-Karthik S S</description>
      <pubDate>Thu, 29 Jan 2004 05:52:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176499#M794085</guid>
      <dc:creator>Karthik S S</dc:creator>
      <dc:date>2004-01-29T05:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: add new string using sed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176500#M794086</link>
      <description>Another method,&lt;BR /&gt;&lt;BR /&gt;create a file (sedfile in this example) with the following two lines,&lt;BR /&gt;&lt;BR /&gt;$a\&lt;BR /&gt;Whatever string you want&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;sed -f sedfile hello.txt&lt;BR /&gt;&lt;BR /&gt;cat hello.txt&lt;BR /&gt;HELLO LINUX&lt;BR /&gt;HELLO WINDOWS&lt;BR /&gt;Whatever string you want&lt;BR /&gt;&lt;BR /&gt;However sed can not substitute the variables with in the input file.&lt;BR /&gt;&lt;BR /&gt;-Karthik S S&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Jan 2004 06:27:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/add-new-string-using-sed/m-p/3176500#M794086</guid>
      <dc:creator>Karthik S S</dc:creator>
      <dc:date>2004-01-29T06:27:20Z</dc:date>
    </item>
  </channel>
</rss>

