<?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: finding file with for loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143683#M453107</link>
    <description>Hi den,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I'd like to avoid this because I don't undertsand why we enter inside the loop. I've no files ! Where is the mistake ?&lt;BR /&gt;&lt;BR /&gt;It will never enter the loop only if the check condition is NULL. Here you are specifying static values.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;for file in $(ls -1 *.txt) ....&lt;BR /&gt;&lt;BR /&gt;would perform better&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 28 Nov 2008 13:29:31 GMT</pubDate>
    <dc:creator>Yogeeraj_1</dc:creator>
    <dc:date>2008-11-28T13:29:31Z</dc:date>
    <item>
      <title>finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143681#M453105</link>
      <description>Hi All&lt;BR /&gt;&lt;BR /&gt;A small question here.&lt;BR /&gt;&lt;BR /&gt;I've no files under /tmp&lt;BR /&gt;My script is something like that&lt;BR /&gt;&lt;BR /&gt;cd /tmp&lt;BR /&gt;for file in *.bak *.txt *.cat *.pll ; do &lt;BR /&gt; cp $file /logs&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Execution Result is&lt;BR /&gt;cp: *.bak: A file or directory in the path name does not exist.&lt;BR /&gt;cp: *.txt: A file or directory in the path name does not exist.&lt;BR /&gt;cp: *.cat: A file or directory in the path name does not exist.&lt;BR /&gt;cp: *.pll: A file or directory in the path name does not exist.&lt;BR /&gt;&lt;BR /&gt;I'd like to avoid this because I don't undertsand why we enter inside the loop. I've no files ! Where is the mistake ?&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Nov 2008 13:18:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143681#M453105</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-11-28T13:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143682#M453106</link>
      <description>Of course I could use &lt;BR /&gt;&lt;BR /&gt;for file in *.bak *.txt *.cat *.pll ; do &lt;BR /&gt; if test -f $file; then&lt;BR /&gt;  cp $file /logs&lt;BR /&gt; fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;But ...</description>
      <pubDate>Fri, 28 Nov 2008 13:23:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143682#M453106</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-11-28T13:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143683#M453107</link>
      <description>Hi den,&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I'd like to avoid this because I don't undertsand why we enter inside the loop. I've no files ! Where is the mistake ?&lt;BR /&gt;&lt;BR /&gt;It will never enter the loop only if the check condition is NULL. Here you are specifying static values.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;for file in $(ls -1 *.txt) ....&lt;BR /&gt;&lt;BR /&gt;would perform better&lt;BR /&gt;&lt;BR /&gt;hope this helps!&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;yogeeraj&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Nov 2008 13:29:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143683#M453107</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2008-11-28T13:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143684#M453108</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;I've always an error &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;___9@cerbere001(/su01/upload) $ for file in $(ls -1 *.bak *.txt *.cat *.pll ) ; do &lt;BR /&gt;&amp;gt;     echo $file &lt;BR /&gt;&amp;gt; done&lt;BR /&gt;ls: 0653-341 The file *.bak does not exist.&lt;BR /&gt;ls: 0653-341 The file *.txt does not exist.&lt;BR /&gt;ls: 0653-341 The file *.cat does not exist.&lt;BR /&gt;ls: 0653-341 The file *.pll does not exist.&lt;BR /&gt;___9@cerbere001(/su01/upload) $ &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Nov 2008 13:52:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143684#M453108</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-11-28T13:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143685#M453109</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;1) This method to suppress the message at cp (my prefered method) will ignore directories, dangling symlinks - just everything that is NOT a plain file:&lt;BR /&gt;&lt;BR /&gt;cd /tmp&lt;BR /&gt;for file in *.bak *.txt *.cat *.pll&lt;BR /&gt;do&lt;BR /&gt;  [ -f $file ] || continue&lt;BR /&gt;  cp $file /logs&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;2) To suppress messages at 'ls' just redirect stderr. The option '-1' (=one=) is useless when not set having a tty, I recommend '-d' because there may be directories matching the pattern:&lt;BR /&gt;for file in $(ls -d *.bak *.txt *.cat *.pll 2&amp;gt;/dev/null)&lt;BR /&gt;do echo $file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 28 Nov 2008 14:23:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143685#M453109</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2008-11-28T14:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143686#M453110</link>
      <description>Sorry - misspelt 2):&lt;BR /&gt;&lt;BR /&gt;2) To suppress messages at 'ls' just redirect stderr. The option '-1' (=one=) is useless when &lt;BR /&gt;not having a tty,&lt;BR /&gt;I recommend '-d' because there may be directories matching the pattern:&lt;BR /&gt;&lt;BR /&gt;for file in $(ls -d *.bak *.txt *.cat *.pll 2&amp;gt;/dev/null)&lt;BR /&gt;do echo $file&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Fri, 28 Nov 2008 14:25:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143686#M453110</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2008-11-28T14:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143687#M453111</link>
      <description>&amp;gt; Where is the mistake ?&lt;BR /&gt;&lt;BR /&gt;Asking about AIX in an HP-UX forum?&lt;BR /&gt;&lt;BR /&gt;Not using "find"?</description>
      <pubDate>Fri, 28 Nov 2008 14:35:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143687#M453111</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-11-28T14:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143688#M453112</link>
      <description>Hi Steven&lt;BR /&gt;&lt;BR /&gt;good. For this effectively Y was for a while with my old friend AIX. &lt;BR /&gt;&lt;BR /&gt;I don't want to use find because I don't want to go on sub-directories... but we have perhaps any find option(s) to avoid search on sub directories... &lt;BR /&gt;&lt;BR /&gt;Thank you very much to All, I've now the solution. &lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Fri, 28 Nov 2008 14:56:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143688#M453112</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-11-28T14:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143689#M453113</link>
      <description>Hi Den:&lt;BR /&gt;&lt;BR /&gt;If you replace your 'cp' with 'echo' you will see that each value in the list is used as an un-evaulated argument to 'cp'.  That is, since glob() doesn't find anything for "*.txt", it is left as "*.txt", generating a "no file" message from 'cp'.&lt;BR /&gt;&lt;BR /&gt;I would do what Peter suggested in scripts like this:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;[ -f ${FILE} ] &amp;amp;&amp;amp; cp ${FILE} /logs&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Steven has a sharp eye!  Your script is *really* running on AIX and not HP-UX.  While that doesn't matter in terms of the problem or of the solution, the error messages are different.&lt;BR /&gt;&lt;BR /&gt;HP-UX reports:&lt;BR /&gt;&lt;BR /&gt;cp: cannot access *.txt: No such file or directory&lt;BR /&gt;&lt;BR /&gt;...whereas AIX gives:&lt;BR /&gt;&lt;BR /&gt;cp: *.txt: A file or directory in the path name does not exist.&lt;BR /&gt;&lt;BR /&gt;It's not nice to fool Mother Nature... :-)&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 28 Nov 2008 14:58:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143689#M453113</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-11-28T14:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143690#M453114</link>
      <description>It' s ok. Thanks to All</description>
      <pubDate>Fri, 28 Nov 2008 15:46:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143690#M453114</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2008-11-28T15:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: finding file with for loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143691#M453115</link>
      <description>&amp;gt; I don't want to use find because I don't&lt;BR /&gt;&amp;gt; want to go on sub-directories... but we&lt;BR /&gt;&amp;gt; have perhaps any find option(s) to avoid&lt;BR /&gt;&amp;gt; search on sub directories... &lt;BR /&gt;&lt;BR /&gt;Easy with GNU "find".  Previous Forum&lt;BR /&gt;discussions showing exactly how should be&lt;BR /&gt;easy to find.&lt;BR /&gt;&lt;BR /&gt;So, you prefer the command-line-too-long&lt;BR /&gt;problems which arise from careless use of&lt;BR /&gt;wildcard file specifications (like "*")?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Steven has a sharp eye!&lt;BR /&gt;&lt;BR /&gt;Not really.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; ls: 0653-341 The file *.bak does not exist.&lt;BR /&gt;&lt;BR /&gt;I've only seen one UNIX (-like) OS which&lt;BR /&gt;has useful error codes like this, and that's&lt;BR /&gt;AIX.  (Very startling for a VMS user to find&lt;BR /&gt;a UNIX OS which showed some evidence of&lt;BR /&gt;having been designed, instead of just cobbled&lt;BR /&gt;together, hence memorable.)</description>
      <pubDate>Fri, 28 Nov 2008 19:19:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/finding-file-with-for-loop/m-p/5143691#M453115</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2008-11-28T19:19:46Z</dc:date>
    </item>
  </channel>
</rss>

