<?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: delete exact word in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552776#M225221</link>
    <description>assuming your text is in file1&lt;BR /&gt;&lt;BR /&gt;cat file1 | sed -e "1,\$s/ xra / /g" &amp;gt;file2&lt;BR /&gt;cat file2 &amp;gt; file1&lt;BR /&gt;cat file1 | sed -e "1,\$s/ xra$//&amp;gt;file2&lt;BR /&gt;cat file2 &amp;gt; file1&lt;BR /&gt;cat file1 | sed -e "1,\$s/^xra //&amp;gt;file2&lt;BR /&gt;cat cat file2 &amp;gt; file1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this should take care of the job</description>
    <pubDate>Thu, 26 May 2005 17:42:37 GMT</pubDate>
    <dc:creator>Mel Burslan</dc:creator>
    <dc:date>2005-05-26T17:42:37Z</dc:date>
    <item>
      <title>delete exact word</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552773#M225218</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;1) I have a line something like this&lt;BR /&gt;&lt;BR /&gt;word abxrage word xra yyxrakba&lt;BR /&gt;&lt;BR /&gt;word xra word word&lt;BR /&gt;&lt;BR /&gt;Want to delete only word xra. Whatever RE I am trying it deletes all occurences of xra.&lt;BR /&gt;&lt;BR /&gt;2) Also I want to delete second &amp;amp; onwards occurence of word xra in a file.&lt;BR /&gt;&lt;BR /&gt;Any help is appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;</description>
      <pubDate>Thu, 26 May 2005 14:50:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552773#M225218</guid>
      <dc:creator>Krish_4</dc:creator>
      <dc:date>2005-05-26T14:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: delete exact word</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552774#M225219</link>
      <description>Krish ..&lt;BR /&gt;&lt;BR /&gt;If you can use vi, then you could use three steps:&lt;BR /&gt;&lt;BR /&gt;:1,$:s/ xra //&lt;BR /&gt;:1,$:s/^xra //&lt;BR /&gt;:1,$:s/ xra$//&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Kent M. Ostby&lt;BR /&gt;</description>
      <pubDate>Thu, 26 May 2005 14:54:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552774#M225219</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2005-05-26T14:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: delete exact word</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552775#M225220</link>
      <description>Can use grep -x command. The -x switch is EXACT match. From here you can pipe into sed or tr, etc</description>
      <pubDate>Thu, 26 May 2005 15:13:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552775#M225220</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2005-05-26T15:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: delete exact word</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552776#M225221</link>
      <description>assuming your text is in file1&lt;BR /&gt;&lt;BR /&gt;cat file1 | sed -e "1,\$s/ xra / /g" &amp;gt;file2&lt;BR /&gt;cat file2 &amp;gt; file1&lt;BR /&gt;cat file1 | sed -e "1,\$s/ xra$//&amp;gt;file2&lt;BR /&gt;cat file2 &amp;gt; file1&lt;BR /&gt;cat file1 | sed -e "1,\$s/^xra //&amp;gt;file2&lt;BR /&gt;cat cat file2 &amp;gt; file1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this should take care of the job</description>
      <pubDate>Thu, 26 May 2005 17:42:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552776#M225221</guid>
      <dc:creator>Mel Burslan</dc:creator>
      <dc:date>2005-05-26T17:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: delete exact word</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552777#M225222</link>
      <description>You have to carefully define what makes a word.&lt;BR /&gt;Is it delimited by spaces only like in your example?&lt;BR /&gt;Could it be delimited by a line begin or end?&lt;BR /&gt;Could it be delimited by a punctuation mark?Any whitespace?&lt;BR /&gt;What do you want done with the whitespace?&lt;BR /&gt;&lt;BR /&gt;Your example, with simple spaces is solved in perl using:&lt;BR /&gt;&lt;BR /&gt;# perl  -itmp -pe "s/ xra / /g" tmp.txt&lt;BR /&gt;&lt;BR /&gt;-p is for 'loop through input and print each line'&lt;BR /&gt;&lt;BR /&gt;The -i is for 'in place'.&lt;BR /&gt;Alternative is:&lt;BR /&gt;&lt;BR /&gt;# perl -pe "s/ xra / /g" tmp.txt &amp;gt; new.txt&lt;BR /&gt;&lt;BR /&gt;Now if you want every single word xra, but not the word parts xra to be replaced the most powerful regexpr component to us is \b which is zero-length word-non-word boundary. Solution with that:&lt;BR /&gt;# perl  -pe "s/\bxra\b//g" tmp.txt&lt;BR /&gt;&lt;BR /&gt;This leaves whitespace as it was, so space-xra-space becomes space-space.&lt;BR /&gt;&lt;BR /&gt;demo (on xp) below.&lt;BR /&gt;Hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# type tmp.txt&lt;BR /&gt;word abxrage word xra yyxrakba&lt;BR /&gt;word xra word word&lt;BR /&gt;Want to delete only word xra. Whatever RE I am trying it deletes all occurences&lt;BR /&gt;of xra.&lt;BR /&gt;xra must go. No more xra&lt;BR /&gt;&lt;BR /&gt;# perl  -itmp -pe "s/ xra / /g" tmp.txt&lt;BR /&gt;&lt;BR /&gt;# type tmp.txt&lt;BR /&gt;word abxrage word yyxrakba&lt;BR /&gt;word word word&lt;BR /&gt;Want to delete only word xra. Whatever RE I am trying it deletes all occurences&lt;BR /&gt;of xra.&lt;BR /&gt;xra must go. No more xra&lt;BR /&gt;&lt;BR /&gt;# perl  -itmp -pe "s/\bxra\b//g" tmp.txt&lt;BR /&gt;&lt;BR /&gt;# type tmp.txt&lt;BR /&gt;word abxrage word yyxrakba&lt;BR /&gt;word word word&lt;BR /&gt;Want to delete only word . Whatever RE I am trying it deletes all occurences of&lt;BR /&gt;.&lt;BR /&gt; must go. No more&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 26 May 2005 21:06:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552777#M225222</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-05-26T21:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: delete exact word</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552778#M225223</link>
      <description>You can sed as,&lt;BR /&gt;&lt;BR /&gt;sed 's/ xra / /g;s/^xra[ ]*//g;s/ xra$//g' &lt;FILENAME&gt; &amp;gt; &lt;NEWFILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;mv &lt;NEWFILENAME&gt; &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;Else directly as,&lt;BR /&gt;&lt;BR /&gt;sed -i 's/ xra / /g;s/^xra[ ]*//g;s/ xra$//g' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;=======&lt;BR /&gt;$ cat testfile&lt;BR /&gt;word abxrage word xra yyxrakba&lt;BR /&gt;word xra word word&lt;BR /&gt;word abxrage word xra yyxrakba xra&lt;BR /&gt;xra  word&lt;BR /&gt;$ sed 's/ xra / /g;s/^xra[ ]*//g;s/ xra$//g' testfile&lt;BR /&gt;word abxrage word yyxrakba&lt;BR /&gt;word word word&lt;BR /&gt;word abxrage word yyxrakba&lt;BR /&gt;word&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/NEWFILENAME&gt;&lt;/NEWFILENAME&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Fri, 27 May 2005 01:49:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/delete-exact-word/m-p/3552778#M225223</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-05-27T01:49:36Z</dc:date>
    </item>
  </channel>
</rss>

