<?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: replace text string and rewrite file script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551881#M917072</link>
    <description>find . -type f | xargs file | grep ascii | cut -d: -f 1 | while read file ; do&lt;BR /&gt; sed "s/oldname/newname/g" $file &amp;gt; $file.new&lt;BR /&gt; mv $file.new $file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;would do it.&lt;BR /&gt;&lt;BR /&gt;Robin.</description>
    <pubDate>Thu, 12 Jul 2001 14:19:14 GMT</pubDate>
    <dc:creator>Robin Wakefield</dc:creator>
    <dc:date>2001-07-12T14:19:14Z</dc:date>
    <item>
      <title>replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551874#M917058</link>
      <description>Hi all,&lt;BR /&gt;I'm looking for a script that'll recursively search files in a directory structure and replace all occurances of a string to the current hostname.&lt;BR /&gt;&lt;BR /&gt;for example I've got around 30 files with a text string enter_hostname and I want a script that when I run the script with for example&lt;BR /&gt;./script -old enter_hostname -new hostname -recurse thisdir&lt;BR /&gt;&lt;BR /&gt;I use find . * |xargs grep enter_hostname to search for the hostname but it finds strings in binary files that I need to avoid rewriting.&lt;BR /&gt;I just want to rewrite text files.&lt;BR /&gt;&lt;BR /&gt;any ideas/suggestions?&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Jul 2001 11:27:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551874#M917058</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2001-07-12T11:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551875#M917059</link>
      <description>&lt;BR /&gt;do a file * in the directory file and grep those that are described as ascii text only.</description>
      <pubDate>Thu, 12 Jul 2001 11:59:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551875#M917059</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2001-07-12T11:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551876#M917060</link>
      <description>Hi Bill:&lt;BR /&gt;&lt;BR /&gt;A quick suggestion is to use 'file' to filter out non-ascii candidates from your process stream.  I know how much you hate 'awk', so:&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;# file /etc/hosts|awk '{print $2}'&lt;BR /&gt;&lt;BR /&gt;...returns ascii&lt;BR /&gt;&lt;BR /&gt;# file /usr/bin/vi|awk '{print $2}'&lt;BR /&gt;&lt;BR /&gt;...returns s800&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 12 Jul 2001 12:02:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551876#M917060</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-07-12T12:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551877#M917061</link>
      <description>Hi Bill,&lt;BR /&gt;you can use command "/usr/bin/file" to check for ascii or  binary.&lt;BR /&gt;&lt;BR /&gt;Sachin</description>
      <pubDate>Thu, 12 Jul 2001 12:44:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551877#M917061</guid>
      <dc:creator>Sachin Patel</dc:creator>
      <dc:date>2001-07-12T12:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551878#M917065</link>
      <description>okay I got that much, but what I want to do is get the script together that'll rewrite the file with the new hostname.&lt;BR /&gt;&lt;BR /&gt;I've got to do some sort of file io script that&lt;BR /&gt;seds the file perhaps and replaces all occurances of string with newstring... and then rewrites the file.&lt;BR /&gt;&lt;BR /&gt;At the moment, I list all files, then vi them all and use :1:$/s/oldstring/newstring/g&lt;BR /&gt;in vi.&lt;BR /&gt;I want a script to do it...&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill</description>
      <pubDate>Thu, 12 Jul 2001 13:53:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551878#M917065</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2001-07-12T13:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551879#M917069</link>
      <description>&lt;BR /&gt;Once youve identified the ascii text filenames then simply do;&lt;BR /&gt;&lt;BR /&gt;cat &lt;FILENAME&gt; | sed 's/&lt;STRING&gt;/&lt;REPLACEMENT string=""&gt;/g' &amp;gt; &lt;NEWFILENAME&gt;&lt;/NEWFILENAME&gt;&lt;/REPLACEMENT&gt;&lt;/STRING&gt;&lt;/FILENAME&gt;</description>
      <pubDate>Thu, 12 Jul 2001 13:59:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551879#M917069</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2001-07-12T13:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551880#M917071</link>
      <description>$ for f in $(file *|grep ascii|cut -d":" -f1)&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; ex ${f} &lt;EXSCRIPT&gt;&lt;/EXSCRIPT&gt;&amp;gt; done&lt;BR /&gt;&lt;BR /&gt;where exscript contains your vi command</description>
      <pubDate>Thu, 12 Jul 2001 14:05:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551880#M917071</guid>
      <dc:creator>Thom Cornwell</dc:creator>
      <dc:date>2001-07-12T14:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551881#M917072</link>
      <description>find . -type f | xargs file | grep ascii | cut -d: -f 1 | while read file ; do&lt;BR /&gt; sed "s/oldname/newname/g" $file &amp;gt; $file.new&lt;BR /&gt; mv $file.new $file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;would do it.&lt;BR /&gt;&lt;BR /&gt;Robin.</description>
      <pubDate>Thu, 12 Jul 2001 14:19:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551881#M917072</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2001-07-12T14:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: replace text string and rewrite file script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551882#M917073</link>
      <description>Hi Bill:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#&lt;BR /&gt;typeset OLD=$1&lt;BR /&gt;typeset NEW=$2&lt;BR /&gt;#&lt;BR /&gt;for F in *&lt;BR /&gt;do&lt;BR /&gt;  if [ `file $F|awk '{print $2}'` = ascii ]&lt;BR /&gt;  then&lt;BR /&gt;    sed "s/$OLD/$NEW/g" $F &amp;gt; ${F}.new&lt;BR /&gt;    mv $F.new $F &lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;#.end.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 12 Jul 2001 14:51:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/replace-text-string-and-rewrite-file-script/m-p/2551882#M917073</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-07-12T14:51:14Z</dc:date>
    </item>
  </channel>
</rss>

