<?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: Scripting Help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020596#M93558</link>
    <description>I use perl unless I need to retain a copy of the original file.&lt;BR /&gt;&lt;BR /&gt;if you intend to change occurances in multiple files within a directory I'd create a for loop, otherwise simply use a perl command. &lt;BR /&gt;&lt;BR /&gt;MULTIFILES&lt;BR /&gt;&lt;BR /&gt;for fn in `ls` &lt;BR /&gt;do &lt;BR /&gt;perl -pi -e s/old/new/g $fn &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Single files &lt;BR /&gt;perl -pi -e s/old/new/g filename &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sun, 17 Jun 2007 21:23:18 GMT</pubDate>
    <dc:creator>rmueller58</dc:creator>
    <dc:date>2007-06-17T21:23:18Z</dc:date>
    <item>
      <title>Scripting Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020589#M93551</link>
      <description>Hello Gurus,&lt;BR /&gt;&lt;BR /&gt;I need to grep for a specific pattern in all the files in a directory and change them to a new pattern.&lt;BR /&gt;&lt;BR /&gt;I tried with sed.&lt;BR /&gt;&lt;BR /&gt;for i in &lt;FILESNAME&gt;&lt;BR /&gt;do&lt;BR /&gt;sed 's/old/new $i &amp;gt; /newdirectory/$i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;it works but the problem is that the files are being truncated when piping to the new file&lt;BR /&gt;&lt;BR /&gt;is there a way i can change the pattern in the same file itself?&lt;BR /&gt;&lt;BR /&gt;thanks in advance&lt;BR /&gt;&lt;/FILESNAME&gt;</description>
      <pubDate>Thu, 14 Jun 2007 23:09:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020589#M93551</guid>
      <dc:creator>George Chechakunnil</dc:creator>
      <dc:date>2007-06-14T23:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020590#M93552</link>
      <description>Your sed solution should work.  You forgot a single quote:&lt;BR /&gt;sed 's/old/new/' $i &amp;gt; /newdirectory/$i&lt;BR /&gt;&lt;BR /&gt;You aren't piping but redirecting.  What was the truncation like??  Number of lines or width of them?   Long long are they??&lt;BR /&gt;&lt;BR /&gt;Changing a pattern the file can be done with perl, search some previous thread.&lt;BR /&gt;&lt;BR /&gt;Some of them show using ex(1) and ed(1) to do this.</description>
      <pubDate>Fri, 15 Jun 2007 02:17:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020590#M93552</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-06-15T02:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020591#M93553</link>
      <description>&lt;!--!*#--&gt;hi,&lt;BR /&gt;&lt;BR /&gt;i have some scripts which does it as follows:&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;  for file in `find . -name "*.htm"`&lt;BR /&gt;  do&lt;BR /&gt;  echo "Converting $file ..."&lt;BR /&gt;  cat $file | sed s/$1/$2/g&amp;gt; /tmp/newfile&lt;BR /&gt;  cp /tmp/newfile $file&lt;BR /&gt;  done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hope this helps too!&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Fri, 15 Jun 2007 02:32:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020591#M93553</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2007-06-15T02:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020592#M93554</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you should perhaps add "g" to your sed statement, e.g.:&lt;BR /&gt;&lt;BR /&gt;sed 's/old/new/g' $i &amp;gt; /tmp/$i&lt;BR /&gt;&lt;BR /&gt;else you will only have the first occurrance replaced.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jun 2007 02:33:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020592#M93554</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2007-06-15T02:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020594#M93556</link>
      <description>hi again,&lt;BR /&gt;&lt;BR /&gt;another way to do it would be using PERL:&lt;BR /&gt;&lt;BR /&gt;perl -pi -e 's/old/new/g' $file&lt;BR /&gt;&lt;BR /&gt;you can replace  the sed command in the previous script with this...&lt;BR /&gt;&lt;BR /&gt;hope this helps too!&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj</description>
      <pubDate>Fri, 15 Jun 2007 02:37:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020594#M93556</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2007-06-15T02:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020595#M93557</link>
      <description>&lt;P&gt;A perl solution was just added to:&lt;BR /&gt;&lt;A href="http://h30499.www3.hp.com/t5/System-Administration/Pattern-replacing/m-p/5053121" target="_blank"&gt;http://h30499.www3.hp.com/t5/System-Administration/Pattern-replacing/m-p/5053121&lt;/A&gt;﻿&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2011 10:39:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020595#M93557</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-09-29T10:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020596#M93558</link>
      <description>I use perl unless I need to retain a copy of the original file.&lt;BR /&gt;&lt;BR /&gt;if you intend to change occurances in multiple files within a directory I'd create a for loop, otherwise simply use a perl command. &lt;BR /&gt;&lt;BR /&gt;MULTIFILES&lt;BR /&gt;&lt;BR /&gt;for fn in `ls` &lt;BR /&gt;do &lt;BR /&gt;perl -pi -e s/old/new/g $fn &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;Single files &lt;BR /&gt;perl -pi -e s/old/new/g filename &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 17 Jun 2007 21:23:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020596#M93558</guid>
      <dc:creator>rmueller58</dc:creator>
      <dc:date>2007-06-17T21:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020597#M93559</link>
      <description>Hi,&lt;BR /&gt;only a sugegstion:&lt;BR /&gt;&lt;BR /&gt;for i in $(grep old *)&lt;BR /&gt;do&lt;BR /&gt;sed 's/old/new' $i &amp;gt; /newdirectory/$i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This will increase teh speed in cas eyou have a lot of files in your dir, and yoy could also refine you grep to get only ascii file, etc.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Mon, 18 Jun 2007 03:07:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/scripting-help/m-p/4020597#M93559</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-06-18T03:07:47Z</dc:date>
    </item>
  </channel>
</rss>

