<?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 regular expressions sed and awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896336#M403294</link>
    <description>I need to use sed or awk to remove characters from a string.  Basically, I want everything removed that's not a letter, number, or space.&lt;BR /&gt;&lt;BR /&gt;So this string:&lt;BR /&gt;&lt;BR /&gt;Hill, "Lefty" Brad (and company)&lt;BR /&gt;&lt;BR /&gt;Becomes:&lt;BR /&gt;&lt;BR /&gt;Hill Lefty Brad and company&lt;BR /&gt;&lt;BR /&gt;No need to worry about other white space, there aren't any tabs etc.&lt;BR /&gt;&lt;BR /&gt;I want to keep:  A-Za-z0-9&lt;BR /&gt;and the space (decimal 32) and the rest can go.&lt;BR /&gt;&lt;BR /&gt;Any way of doing this without explicitly naming 'the rest'?&lt;BR /&gt;</description>
    <pubDate>Fri, 15 Apr 2005 10:56:16 GMT</pubDate>
    <dc:creator>Fred Martin_1</dc:creator>
    <dc:date>2005-04-15T10:56:16Z</dc:date>
    <item>
      <title>regular expressions sed and awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896336#M403294</link>
      <description>I need to use sed or awk to remove characters from a string.  Basically, I want everything removed that's not a letter, number, or space.&lt;BR /&gt;&lt;BR /&gt;So this string:&lt;BR /&gt;&lt;BR /&gt;Hill, "Lefty" Brad (and company)&lt;BR /&gt;&lt;BR /&gt;Becomes:&lt;BR /&gt;&lt;BR /&gt;Hill Lefty Brad and company&lt;BR /&gt;&lt;BR /&gt;No need to worry about other white space, there aren't any tabs etc.&lt;BR /&gt;&lt;BR /&gt;I want to keep:  A-Za-z0-9&lt;BR /&gt;and the space (decimal 32) and the rest can go.&lt;BR /&gt;&lt;BR /&gt;Any way of doing this without explicitly naming 'the rest'?&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Apr 2005 10:56:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896336#M403294</guid>
      <dc:creator>Fred Martin_1</dc:creator>
      <dc:date>2005-04-15T10:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions sed and awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896337#M403295</link>
      <description>echo 'Hill, "Lefty" Brad (and company)' | tr -c -d [^A-Za-z0-9\ ]&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Apr 2005 12:01:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896337#M403295</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-04-15T12:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions sed and awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896338#M403296</link>
      <description>I think Hein's solution using 'tr' is a lot compact and &lt;BR /&gt;nice, but if you must do it in sed, here is how you do &lt;BR /&gt;it:&lt;BR /&gt;&lt;BR /&gt;str1='Hi, "Lefty" Brad (and company)'&lt;BR /&gt;str2=$(echo $str1 | sed 's/[A-Za-z0-9 ]//g')&lt;BR /&gt;str3=$(echo $str1 | sed "s/[$str2]//g")&lt;BR /&gt;echo $str3&lt;BR /&gt;&lt;BR /&gt;You could read str1 from your input file directly.&lt;BR /&gt;&lt;BR /&gt;- Biswajit&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Apr 2005 12:48:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896338#M403296</guid>
      <dc:creator>Biswajit Tripathy</dc:creator>
      <dc:date>2005-04-15T12:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions sed and awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896339#M403297</link>
      <description>Or make it a little more compact :&lt;BR /&gt;&lt;BR /&gt;str1='Hi, "Lefty" Brad (and company)'&lt;BR /&gt;echo $(echo $str1 | sed "s/[$(echo $str1 | sed 's/[A-Za-z0-9 ]//g')]//g")&lt;BR /&gt;&lt;BR /&gt;- Biswajit&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Apr 2005 12:52:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896339#M403297</guid>
      <dc:creator>Biswajit Tripathy</dc:creator>
      <dc:date>2005-04-15T12:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions sed and awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896340#M403298</link>
      <description>Nicely done with 'tr' - I was unaware of those switches so I hadn't considered using it.&lt;BR /&gt;&lt;BR /&gt;However, the command appears to also remove the carriage return at the end of the string.&lt;BR /&gt;&lt;BR /&gt;How can that be prevented?&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Apr 2005 13:43:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896340#M403298</guid>
      <dc:creator>Fred Martin_1</dc:creator>
      <dc:date>2005-04-15T13:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions sed and awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896341#M403299</link>
      <description>Easy, add it to the list of characters to keep:&lt;BR /&gt;&lt;BR /&gt;lt09:/home/merijn 122 &amp;gt; cat xx.txt&lt;BR /&gt;Hill, "Lefty" Brad (and company)&lt;BR /&gt;lt09:/home/merijn 123 &amp;gt; tr -c -d '[A-Za-z0-9 ]' &amp;lt; xx.txt&lt;BR /&gt;Hill Lefty Brad and companylt09:/home/merijn 124 &amp;gt; tr -c -d '[A-Za-z0-9 \n]' &amp;lt; xx.txt&lt;BR /&gt;Hill Lefty Brad and company&lt;BR /&gt;lt09:/home/merijn 125 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Is perl an option too?&lt;BR /&gt;&lt;BR /&gt;lt09:/home/merijn 126 &amp;gt; perl -ple's/[^\w ]+//g' &amp;lt; xx.txt&lt;BR /&gt;Hill Lefty Brad and company&lt;BR /&gt;lt09:/home/merijn 127 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 15 Apr 2005 13:56:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896341#M403299</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-04-15T13:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions sed and awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896342#M403300</link>
      <description>Ahh, the \n thing did the trick.  Many thanks.&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Apr 2005 13:58:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/regular-expressions-sed-and-awk/m-p/4896342#M403300</guid>
      <dc:creator>Fred Martin_1</dc:creator>
      <dc:date>2005-04-15T13:58:25Z</dc:date>
    </item>
  </channel>
</rss>

