<?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: Query in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022480#M428852</link>
    <description>this is untested - but should get you close&lt;BR /&gt;.....&lt;BR /&gt;&lt;BR /&gt;for i in `find . -type f \&lt;BR /&gt;| xargs -i grep -l "\/var\/log\/test" {} `&lt;BR /&gt;do&lt;BR /&gt;echo ------ fixing file $i -------&lt;BR /&gt;cat $i | sed "s/\/var\/log\/test/\/var\/log\/prod/" &amp;gt; $i.new&lt;BR /&gt;# Uncomment the following lines to remove&lt;BR /&gt;# to remove the .new file if you are &lt;BR /&gt;# comfortable with how this thing works,&lt;BR /&gt;# and have seen it run sucessfully for a&lt;BR /&gt;# while, otherwise it probably does no harm &lt;BR /&gt;# to leave it - providing there are no&lt;BR /&gt;# security or space issues in leaving the&lt;BR /&gt;# these files in place.&lt;BR /&gt;# rm $i.new&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;If you need to actually have the new file replace the old one (instead of just having a new file with the ".new" extension on it).&lt;BR /&gt;&lt;BR /&gt;for i in `find . -type f \&lt;BR /&gt;| xargs -i grep -l "\/var\/log\/test" {} `&lt;BR /&gt;do&lt;BR /&gt;echo ------ fixing file $i -------&lt;BR /&gt;cat $i | sed "s/\/var\/log\/test/\/var\/log\/prod/" &amp;gt; $i.new&lt;BR /&gt;cp $i $i.old.keep.bak&lt;BR /&gt;cp $i.new $i&lt;BR /&gt;# Uncomment the following lines to remove&lt;BR /&gt;# to remove the .new file and the backup file&lt;BR /&gt;# if you are comfortable with how this thing&lt;BR /&gt;# works, and have seen it run sucessfully for &lt;BR /&gt;# a while, otherwise it probably does no harm &lt;BR /&gt;# to leave it - providing there are no&lt;BR /&gt;# security or space issues in leaving the&lt;BR /&gt;# these files in place.&lt;BR /&gt;# rm $i.new&lt;BR /&gt;# rm $i.old.keep.bak&lt;BR /&gt;done</description>
    <pubDate>Thu, 11 Jan 2007 18:54:42 GMT</pubDate>
    <dc:creator>TwoProc</dc:creator>
    <dc:date>2007-01-11T18:54:42Z</dc:date>
    <item>
      <title>Query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022477#M428849</link>
      <description>I have about 25 files in which I need to convert the string /var/log/test to /var/log/prod ... &lt;BR /&gt;&lt;BR /&gt;find . -name "*.*"|xargs grep "/var/log/test" &lt;BR /&gt;&lt;BR /&gt;Can I make a change thru command line instead of going into each and every file . I am looking for an exact answer.&lt;BR /&gt;&lt;BR /&gt;thanks,&lt;BR /&gt;hunki</description>
      <pubDate>Thu, 11 Jan 2007 18:26:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022477#M428849</guid>
      <dc:creator>Hunki</dc:creator>
      <dc:date>2007-01-11T18:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: Query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022478#M428850</link>
      <description>yeah, for example it's possible to feed vi with commands from file</description>
      <pubDate>Thu, 11 Jan 2007 18:34:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022478#M428850</guid>
      <dc:creator>Michal Toth</dc:creator>
      <dc:date>2007-01-11T18:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022479#M428851</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Use Perl and you can make your updates inplace while creating a backup copy of the original files:&lt;BR /&gt;&lt;BR /&gt;# perl -pi.old -e 's%/var/log/test\b%/var/log/prod%g' file1 file2 file3 ...&lt;BR /&gt;&lt;BR /&gt;This will replace the string "/var/log/test" with "/var/log/prod" in every file passed as an argument.  For each file (argument) the original file will be preserved as "*.old".&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jan 2007 18:50:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022479#M428851</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-01-11T18:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: Query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022480#M428852</link>
      <description>this is untested - but should get you close&lt;BR /&gt;.....&lt;BR /&gt;&lt;BR /&gt;for i in `find . -type f \&lt;BR /&gt;| xargs -i grep -l "\/var\/log\/test" {} `&lt;BR /&gt;do&lt;BR /&gt;echo ------ fixing file $i -------&lt;BR /&gt;cat $i | sed "s/\/var\/log\/test/\/var\/log\/prod/" &amp;gt; $i.new&lt;BR /&gt;# Uncomment the following lines to remove&lt;BR /&gt;# to remove the .new file if you are &lt;BR /&gt;# comfortable with how this thing works,&lt;BR /&gt;# and have seen it run sucessfully for a&lt;BR /&gt;# while, otherwise it probably does no harm &lt;BR /&gt;# to leave it - providing there are no&lt;BR /&gt;# security or space issues in leaving the&lt;BR /&gt;# these files in place.&lt;BR /&gt;# rm $i.new&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;If you need to actually have the new file replace the old one (instead of just having a new file with the ".new" extension on it).&lt;BR /&gt;&lt;BR /&gt;for i in `find . -type f \&lt;BR /&gt;| xargs -i grep -l "\/var\/log\/test" {} `&lt;BR /&gt;do&lt;BR /&gt;echo ------ fixing file $i -------&lt;BR /&gt;cat $i | sed "s/\/var\/log\/test/\/var\/log\/prod/" &amp;gt; $i.new&lt;BR /&gt;cp $i $i.old.keep.bak&lt;BR /&gt;cp $i.new $i&lt;BR /&gt;# Uncomment the following lines to remove&lt;BR /&gt;# to remove the .new file and the backup file&lt;BR /&gt;# if you are comfortable with how this thing&lt;BR /&gt;# works, and have seen it run sucessfully for &lt;BR /&gt;# a while, otherwise it probably does no harm &lt;BR /&gt;# to leave it - providing there are no&lt;BR /&gt;# security or space issues in leaving the&lt;BR /&gt;# these files in place.&lt;BR /&gt;# rm $i.new&lt;BR /&gt;# rm $i.old.keep.bak&lt;BR /&gt;done</description>
      <pubDate>Thu, 11 Jan 2007 18:54:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022480#M428852</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2007-01-11T18:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022481#M428853</link>
      <description>&lt;!--!*#--&gt;Somethign like this perl script is most optimal... but too much work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;while (&lt;X&gt;) {&lt;BR /&gt;  my $count = 0;&lt;BR /&gt;  my $file = $_;&lt;BR /&gt;  my @lines;&lt;BR /&gt;  open (OLD, "&amp;lt;$file");&lt;BR /&gt;  while (&lt;OLD&gt;) {&lt;BR /&gt;     $count += s%/var/log/test\b%/var/log/prod%g;&lt;BR /&gt;     push @lines, $_;&lt;BR /&gt;     }&lt;BR /&gt;  close OLD;&lt;BR /&gt;  if ($count) {&lt;BR /&gt;    $_ = $file;&lt;BR /&gt;    s/\..*?$/.old/;&lt;BR /&gt;    rename $file, $_;&lt;BR /&gt;    open (NEW, "&amp;gt;$file");&lt;BR /&gt;    print NEW @lines;&lt;BR /&gt;    close NEW;&lt;BR /&gt;  }&lt;BR /&gt;}&lt;/OLD&gt;&lt;/X&gt;</description>
      <pubDate>Thu, 11 Jan 2007 23:23:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022481#M428853</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-01-11T23:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022482#M428854</link>
      <description>Thanks to All specially JRF.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 12 Jan 2007 11:41:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/query/m-p/5022482#M428854</guid>
      <dc:creator>Hunki</dc:creator>
      <dc:date>2007-01-12T11:41:04Z</dc:date>
    </item>
  </channel>
</rss>

