<?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: pattern search and replace in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850630#M274791</link>
    <description>The simplest is to use grep to extract all the IP addresses you want:&lt;BR /&gt; &lt;BR /&gt;grep -e 120.340.056.078 -e 012.012.013.103 -e 020.030.040.050 -e 015.016.170.180 your_filename&lt;BR /&gt; &lt;BR /&gt;Note that this assumes you want just certain addressess and that all addresses have the same format (ie ###.###.###.###) but if the addresses have leading zeros stripped (ie, 12 rather than 012), then you'll have to match exactly what is in the file.&lt;BR /&gt; &lt;BR /&gt;To change a record that matches your search criteria, you'll need to use awk or a shell  or Perl script.</description>
    <pubDate>Fri, 25 Aug 2006 11:57:33 GMT</pubDate>
    <dc:creator>Bill Hassell</dc:creator>
    <dc:date>2006-08-25T11:57:33Z</dc:date>
    <item>
      <title>pattern search and replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850626#M274787</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a text file with configuration information gathered from my systems.&lt;BR /&gt;&lt;BR /&gt;I need to search those files for any IP address and delete it or mask it.  I might have different IP addresses in the same file.  So I am looking for a pattern like xxx.xxx.xxx.xxx to delete or maske.&lt;BR /&gt;&lt;BR /&gt;How can I do that?&lt;BR /&gt;&lt;BR /&gt;thank you in advance</description>
      <pubDate>Fri, 25 Aug 2006 11:39:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850626#M274787</guid>
      <dc:creator>moonchild</dc:creator>
      <dc:date>2006-08-25T11:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: pattern search and replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850627#M274788</link>
      <description>you can open the file with vi and do this way&lt;BR /&gt;:$s/oldstring/newstring/g&lt;BR /&gt;&lt;BR /&gt;which will replace oldstring to newstring globally in the file.</description>
      <pubDate>Fri, 25 Aug 2006 11:41:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850627#M274788</guid>
      <dc:creator>IT_2007</dc:creator>
      <dc:date>2006-08-25T11:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: pattern search and replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850628#M274789</link>
      <description>There are many ways to do this. Among them are sed, Perl, and awk. I'll use sed this time:&lt;BR /&gt;&lt;BR /&gt;sed -e '/dog/d' -e '/cat/d' -e 's/cow/Giraffe/g' &amp;lt; infile &amp;gt; outfile&lt;BR /&gt;&lt;BR /&gt;This would read infile and delete every line that contains 'dog' or 'cat' and substitutes "Giraffe" for every instance of "cow" and write the result to outfile.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Aug 2006 11:50:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850628#M274789</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-08-25T11:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: pattern search and replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850629#M274790</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;If you want to change an address pattern, you could use:&lt;BR /&gt;&lt;BR /&gt;# perl -pe 's/\Q127.0.0.1/127.0.0.2/' file&lt;BR /&gt;&lt;BR /&gt;...and if you wanted to delete lines containing it:&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'print unless m/\Q127.0.0.1/' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 25 Aug 2006 11:56:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850629#M274790</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-08-25T11:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: pattern search and replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850630#M274791</link>
      <description>The simplest is to use grep to extract all the IP addresses you want:&lt;BR /&gt; &lt;BR /&gt;grep -e 120.340.056.078 -e 012.012.013.103 -e 020.030.040.050 -e 015.016.170.180 your_filename&lt;BR /&gt; &lt;BR /&gt;Note that this assumes you want just certain addressess and that all addresses have the same format (ie ###.###.###.###) but if the addresses have leading zeros stripped (ie, 12 rather than 012), then you'll have to match exactly what is in the file.&lt;BR /&gt; &lt;BR /&gt;To change a record that matches your search criteria, you'll need to use awk or a shell  or Perl script.</description>
      <pubDate>Fri, 25 Aug 2006 11:57:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850630#M274791</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2006-08-25T11:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: pattern search and replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850631#M274792</link>
      <description>This might not be the best way, but you can strip all IP patterns out of a file pretty easy with perl.&lt;BR /&gt;&lt;BR /&gt;perl -p -e 's/([\d]+)\.([\d]+)\.([\d]+)\.([\d]+)//' file&lt;BR /&gt;&lt;BR /&gt;if you wanted to delete them from the file completely. &lt;BR /&gt;&lt;BR /&gt;perl -pi -e 's/([\d]+)\.([\d]+)\.([\d]+)\.([\d]+)//' file&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Aug 2006 13:17:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850631#M274792</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-08-25T13:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: pattern search and replace</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850632#M274793</link>
      <description>Marvin,&lt;BR /&gt;&lt;BR /&gt;I am new to scripting and perl.&lt;BR /&gt;&lt;BR /&gt;How can I put the command you suggested in a shell script so I apply it on all the files in a directory? I am trying the following but it's not working but if I run your command on a specific file from the command line it works fine.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;for FILE  in `ls *.html`&lt;BR /&gt;do&lt;BR /&gt;{&lt;BR /&gt;  perl -p -e 's/([\d]+)\.([\d]+)\.([\d]+)\.([\d]+)//' $FILE &amp;gt; noip-$FILE;&lt;BR /&gt;}&lt;BR /&gt;done</description>
      <pubDate>Mon, 28 Aug 2006 15:35:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/pattern-search-and-replace/m-p/3850632#M274793</guid>
      <dc:creator>moonchild</dc:creator>
      <dc:date>2006-08-28T15:35:47Z</dc:date>
    </item>
  </channel>
</rss>

