<?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: Upload file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362664#M194366</link>
    <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;Here's a really quick/dirty way to do it.  I'm sure there are many more elaborate ways, and several more checks you can add to make it work to your liking:&lt;BR /&gt;&lt;BR /&gt;for FILE in $(find /home/.)&lt;BR /&gt;do&lt;BR /&gt;        if [ ! -x $FILE ]&lt;BR /&gt;        then&lt;BR /&gt;                grep "SUCCESS" $FILE &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;                if [ $? -eq 0 ]&lt;BR /&gt;                then&lt;BR /&gt;                        cat $FILE | sed "s/SUCCESS/FAIL/g" &amp;gt; $FILE.new&lt;BR /&gt;                fi&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This script checks to see that the file is not an executable and it ensures that the string "SUCCESS" appears in the file before modifying it.  The original file is left intact and a new file with a ".new" extension is created.&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;BR /&gt;&lt;BR /&gt;Dave</description>
    <pubDate>Sun, 22 Aug 2004 23:44:05 GMT</pubDate>
    <dc:creator>Dave Olker</dc:creator>
    <dc:date>2004-08-22T23:44:05Z</dc:date>
    <item>
      <title>Upload file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362663#M194365</link>
      <description>I ask this question before , but I have one more requirement.&lt;BR /&gt;&lt;BR /&gt;I want to replace all the word "SUCCESS" to "FAIL" in all files under the directory /home ( include all sub-directories ) , what can I do ? thx in advance.</description>
      <pubDate>Sun, 22 Aug 2004 22:10:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362663#M194365</guid>
      <dc:creator>peterchu</dc:creator>
      <dc:date>2004-08-22T22:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362664#M194366</link>
      <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;Here's a really quick/dirty way to do it.  I'm sure there are many more elaborate ways, and several more checks you can add to make it work to your liking:&lt;BR /&gt;&lt;BR /&gt;for FILE in $(find /home/.)&lt;BR /&gt;do&lt;BR /&gt;        if [ ! -x $FILE ]&lt;BR /&gt;        then&lt;BR /&gt;                grep "SUCCESS" $FILE &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;                if [ $? -eq 0 ]&lt;BR /&gt;                then&lt;BR /&gt;                        cat $FILE | sed "s/SUCCESS/FAIL/g" &amp;gt; $FILE.new&lt;BR /&gt;                fi&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This script checks to see that the file is not an executable and it ensures that the string "SUCCESS" appears in the file before modifying it.  The original file is left intact and a new file with a ".new" extension is created.&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;BR /&gt;&lt;BR /&gt;Dave</description>
      <pubDate>Sun, 22 Aug 2004 23:44:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362664#M194366</guid>
      <dc:creator>Dave Olker</dc:creator>
      <dc:date>2004-08-22T23:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362665#M194367</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Take a look at this link:&lt;BR /&gt;&lt;A href="http://www.dslreports.com/forum/remark,10607506~mode=flat" target="_blank"&gt;http://www.dslreports.com/forum/remark,10607506~mode=flat&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;Regards,&lt;BR /&gt;Sri Ram</description>
      <pubDate>Mon, 23 Aug 2004 00:26:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362665#M194367</guid>
      <dc:creator>R. Sri Ram Kishore_1</dc:creator>
      <dc:date>2004-08-23T00:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362666#M194368</link>
      <description>thx replies,&lt;BR /&gt;&lt;BR /&gt;I try the methods is ok, but it will copy a backup to $FILE.bak , how can I directly update the files instead of make a backup file ? thx.</description>
      <pubDate>Mon, 23 Aug 2004 01:14:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362666#M194368</guid>
      <dc:creator>peterchu</dc:creator>
      <dc:date>2004-08-23T01:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362667#M194369</link>
      <description>Hi Peter,&lt;BR /&gt;&lt;BR /&gt;If you wanted to use the logic I posted previously, just change the line:&lt;BR /&gt;&lt;BR /&gt;cat $FILE | sed "s/SUCCESS/FAIL/g" &amp;gt; $FILE.new&lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt;cat $FILE | sed "s/SUCCESS/FAIL/g" &amp;gt; $FILE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;That will replace the existing file with the modified content.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Dave</description>
      <pubDate>Mon, 23 Aug 2004 10:43:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362667#M194369</guid>
      <dc:creator>Dave Olker</dc:creator>
      <dc:date>2004-08-23T10:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362668#M194370</link>
      <description>Here's one-liner with perl&lt;BR /&gt;&lt;BR /&gt;find /home -type f -exec perl -pi -e 's,SUCCESS,FAIL,g' {} \;&lt;BR /&gt;&lt;BR /&gt;Be careful with&lt;BR /&gt;&lt;BR /&gt;cat $FILE | sed "s/SUCCESS/FAIL/g" &amp;gt; $FILE&lt;BR /&gt;&lt;BR /&gt;I think shell will process redirections before executing any commands. Which means that $FILE will get clobbered before cat gets to it.</description>
      <pubDate>Wed, 25 Aug 2004 01:34:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362668#M194370</guid>
      <dc:creator>Ermin Borovac</dc:creator>
      <dc:date>2004-08-25T01:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362669#M194371</link>
      <description>We can do it with sed / perl here.&lt;BR /&gt;&lt;BR /&gt; Perl is easy to do as,&lt;BR /&gt;&lt;BR /&gt; perl -p -i -e 's/SUCCESS/FAIL/g' filename.&lt;BR /&gt;&lt;BR /&gt; You can collect all files using find command as,&lt;BR /&gt;&lt;BR /&gt; find &lt;DIR&gt; -name "filenamepattern" -exec perl -p -i -e 's/SUCCESS/FAIL/g' {} \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; You can do it with sed as &lt;BR /&gt;&lt;BR /&gt; echo "sed -e 's/SUCCESS/FAIL/g' filename" &amp;gt; filename&lt;BR /&gt;&lt;BR /&gt; It will do the changes for one file with using temp. files.&lt;BR /&gt;&lt;BR /&gt; You can do on multiple files as,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; grep -l "SUCCESS" &lt;DIR&gt; | awk '{ print "echo \"`sed -e 's/SUCCESS/FAIL/g' "$0 "`\" &amp;gt; "$1 }' | sh&lt;BR /&gt;&lt;BR /&gt; It will change all patterns of SUCCESS on all files. If you want to know what is happeneing just remove | sh on execution it will print single file execution statements for all files.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Muthu&lt;/DIR&gt;&lt;/DIR&gt;</description>
      <pubDate>Wed, 25 Aug 2004 02:37:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/upload-file/m-p/3362669#M194371</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-08-25T02:37:35Z</dc:date>
    </item>
  </channel>
</rss>

