<?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: script - help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728337#M100975</link>
    <description>To remove the contents of the existing html files in your directory&lt;BR /&gt;&lt;BR /&gt;ls *.html | while read line&lt;BR /&gt;do&lt;BR /&gt;cat /dev/null &amp;gt; $line&lt;BR /&gt;done&lt;BR /&gt;This will keep the files in place but they will have 0 bytes in size.&lt;BR /&gt;&lt;BR /&gt;To put something in a file&lt;BR /&gt;ls *.html | while read line&lt;BR /&gt;do&lt;BR /&gt;echo "This is the new stuff" &amp;gt; $line&lt;BR /&gt;done&lt;BR /&gt;</description>
    <pubDate>Thu, 09 Feb 2006 17:36:55 GMT</pubDate>
    <dc:creator>Rick Garland</dc:creator>
    <dc:date>2006-02-09T17:36:55Z</dc:date>
    <item>
      <title>script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728333#M100971</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a nearly 120 html files in one server. Now we have migrated the files to a new server.&lt;BR /&gt;&lt;BR /&gt;So I have written a redirect script which would redirect to the new server.&lt;BR /&gt;&lt;BR /&gt;Now I would need to remove the contents of each html file and put the content of my redirect script in each of the HTML file.&lt;BR /&gt;&lt;BR /&gt;Can anyone please tell me if I can remove the entire content of each file and put the content of my redirect script in each file.&lt;BR /&gt;&lt;BR /&gt;I am not good in PERL or SHELL scripting.&lt;BR /&gt;&lt;BR /&gt;Please help.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pat</description>
      <pubDate>Thu, 09 Feb 2006 15:13:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728333#M100971</guid>
      <dc:creator>Pat Peter</dc:creator>
      <dc:date>2006-02-09T15:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728334#M100972</link>
      <description>Use sed&lt;BR /&gt;&lt;BR /&gt;sed 's/serverold/servernew/g' somefile.html &amp;gt; somenewfile.html&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Thu, 09 Feb 2006 16:17:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728334#M100972</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-02-09T16:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728335#M100973</link>
      <description>If you're talking about doing a massive update to several html files where you need to change the paths to the new server, then perl could do it in one line-&lt;BR /&gt; &lt;BR /&gt;perl -i -p -e 's{old/path}{new/path}g' *.html&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Thu, 09 Feb 2006 16:18:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728335#M100973</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2006-02-09T16:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728336#M100974</link>
      <description>HI,&lt;BR /&gt;&lt;BR /&gt;I think I was not very clear on my requirement in my thread.&lt;BR /&gt;&lt;BR /&gt;What I want to do is &lt;BR /&gt;&lt;BR /&gt;1. remove the entire contents of existing .html files in my directory.&lt;BR /&gt;2. Copy the content of one of the files in another directory to all the .html files in my directory.&lt;BR /&gt;&lt;BR /&gt;Hope this one is littl emore clear.&lt;BR /&gt;&lt;BR /&gt;Please help me.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pat</description>
      <pubDate>Thu, 09 Feb 2006 17:31:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728336#M100974</guid>
      <dc:creator>Pat Peter</dc:creator>
      <dc:date>2006-02-09T17:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728337#M100975</link>
      <description>To remove the contents of the existing html files in your directory&lt;BR /&gt;&lt;BR /&gt;ls *.html | while read line&lt;BR /&gt;do&lt;BR /&gt;cat /dev/null &amp;gt; $line&lt;BR /&gt;done&lt;BR /&gt;This will keep the files in place but they will have 0 bytes in size.&lt;BR /&gt;&lt;BR /&gt;To put something in a file&lt;BR /&gt;ls *.html | while read line&lt;BR /&gt;do&lt;BR /&gt;echo "This is the new stuff" &amp;gt; $line&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Feb 2006 17:36:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728337#M100975</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2006-02-09T17:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728338#M100976</link>
      <description>Hi Pat:&lt;BR /&gt;&lt;BR /&gt;Based upon your last specification you could do this to overlay all of your files with a copy of another:&lt;BR /&gt;&lt;BR /&gt;# find &lt;PATH&gt; -type f -name "*.html" | xargs -i cp /tmp/overlay {}&lt;BR /&gt;&lt;BR /&gt;The /tmp/overlay file will replace every file in &lt;PATH&gt; whose filename ends in ".html".&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/PATH&gt;&lt;/PATH&gt;</description>
      <pubDate>Thu, 09 Feb 2006 17:46:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728338#M100976</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-09T17:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728339#M100977</link>
      <description>Clear as mud - sorry...&lt;BR /&gt;&lt;BR /&gt;Are you saying, you want to keep all 120 html files, but make them empty?  and then copy the contents of 1 file to all 120  html files?&lt;BR /&gt;&lt;BR /&gt;cd /directoryof/existing/files&lt;BR /&gt;&lt;BR /&gt;for i in `ls`&lt;BR /&gt;do&lt;BR /&gt;&amp;gt; $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;for i in `ls`&lt;BR /&gt;do&lt;BR /&gt;cat /directoryof/myredirectscript &amp;gt; $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Feb 2006 17:47:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728339#M100977</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-02-09T17:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728340#M100978</link>
      <description>Sorry - for html only, change my ls command to `ls *.html`  or `ls *.htm` just incase there are other files you don't want clobbered...&lt;BR /&gt;&lt;BR /&gt;While we are at it - make sure you have a good backup of those files...&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff</description>
      <pubDate>Thu, 09 Feb 2006 17:51:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728340#M100978</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2006-02-09T17:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728341#M100979</link>
      <description>Hi Rick,&lt;BR /&gt;&lt;BR /&gt;The first part in your solution really helps. I am able to create the empty files by doing that.&lt;BR /&gt;&lt;BR /&gt;But in the second step, I have a file called "redirect". I need to copy the content of this file to all the .html files.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pat</description>
      <pubDate>Thu, 09 Feb 2006 17:52:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728341#M100979</guid>
      <dc:creator>Pat Peter</dc:creator>
      <dc:date>2006-02-09T17:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728342#M100980</link>
      <description>Hi (again) Pat:&lt;BR /&gt;&lt;BR /&gt;Unless I am misunderstanding you, you need to reexamine tha suggestion I offered using 'find' and 'xargs'.  See the manpages for 'xargs' (particulary) to see how this technique works.&lt;BR /&gt;&lt;BR /&gt;find &lt;PATH&gt; -type f -name "*.html" | xargs -i cp redirect {}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/PATH&gt;</description>
      <pubDate>Thu, 09 Feb 2006 18:46:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728342#M100980</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-09T18:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728343#M100981</link>
      <description>Hi,&lt;BR /&gt;for FILE in $(ls -1 *.html)&lt;BR /&gt;do&lt;BR /&gt;  &amp;gt; $FILE&lt;BR /&gt;  cat redirect &amp;gt;$FILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;thsi will empty all the 8.html file in your directory and put the content of the file rediurect into the same files.&lt;BR /&gt;&lt;BR /&gt;N.B. I don't understand why you want clean the files before? is not sufficient to replce teh contents (if yes remove &amp;gt; $FILE)&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Fri, 10 Feb 2006 05:53:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728343#M100981</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2006-02-10T05:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728344#M100982</link>
      <description>You can use perl to update the change in the same file easily as,&lt;BR /&gt;&lt;BR /&gt;# cat 1.html&lt;BR /&gt;&lt;BR /&gt;test&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# perl -pi -e 's/test/Pat/g' *.html&lt;BR /&gt;# cat 1.html&lt;BR /&gt;&lt;BR /&gt;Pat&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It is best method for not using any temporary files.&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
      <pubDate>Fri, 10 Feb 2006 06:00:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728344#M100982</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-02-10T06:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: script - help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728345#M100983</link>
      <description>The first part in your solution really helps. I am able to create the empty files by doing that.&lt;BR /&gt;&lt;BR /&gt;But in the second step, I have a file called "redirect". I need to copy the content of this file to all the .html files.&lt;BR /&gt;&lt;BR /&gt;==&amp;gt;&lt;BR /&gt;&lt;BR /&gt;It is confusing. Do you want to create files then simply as,&lt;BR /&gt;&lt;BR /&gt;# &amp;gt; filename&lt;BR /&gt;&lt;BR /&gt;If you want to copy the contents of redirect to new files then,&lt;BR /&gt;&lt;BR /&gt;# cp redirect &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;In loop,&lt;BR /&gt;&lt;BR /&gt;i=1&lt;BR /&gt;while [[ ${i} -lt 101 ]]&lt;BR /&gt;do&lt;BR /&gt;  cp redirect ${i}.html&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu&lt;/FILENAME&gt;</description>
      <pubDate>Fri, 10 Feb 2006 06:05:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/3728345#M100983</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-02-10T06:05:35Z</dc:date>
    </item>
  </channel>
</rss>

