<?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: find script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140095#M155124</link>
    <description>How about in perl. This uses "ls -1R" to generate list of all filenames. It goes through the file system once and generates a list of all directories the filename is located.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl &lt;BR /&gt;$startdir="/";&lt;BR /&gt;open(INP,"&lt;YOURFILELIST&gt;&lt;/YOURFILELIST&gt;while(&lt;INP&gt;) { chomp; $names{$_}=[]; }&lt;BR /&gt;close(INP);&lt;BR /&gt;$lastdir=$startdir;&lt;BR /&gt;open(LS,"ls -1R $startdir|");&lt;BR /&gt;while(&lt;LS&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;next unless $_;&lt;BR /&gt;if (substr($_,0,1) eq "/") { $lastdir=$_; }&lt;BR /&gt;else {&lt;BR /&gt;push(@{$names{$_}},$lastdir) if $names{$_};&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;close(LS);&lt;BR /&gt;foreach $name (sort keys %names) {&lt;BR /&gt; $dirs=$names{$name};&lt;BR /&gt; if (scalar @$dirs) {&lt;BR /&gt;  print $name," ",join(",",@$dirs),"\n";&lt;BR /&gt; } else {&lt;BR /&gt;  print $name," NOT FOUND...\n";&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;/LS&gt;&lt;/INP&gt;</description>
    <pubDate>Tue, 09 Dec 2003 13:45:33 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2003-12-09T13:45:33Z</dc:date>
    <item>
      <title>find script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140089#M155118</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;We would like to script a find file search, currentlyhave a file containing a list of files &amp;amp; want to do a&lt;BR /&gt;"find" for the file and to out put that the file was found and is in x directory. The script must also&lt;BR /&gt;cater for files not found. Any ideas would be most appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!</description>
      <pubDate>Tue, 09 Dec 2003 11:43:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140089#M155118</guid>
      <dc:creator>Edgar_8</dc:creator>
      <dc:date>2003-12-09T11:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: find script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140090#M155119</link>
      <description>Say you have a list of files to be found in file input file.&lt;BR /&gt;&lt;BR /&gt;for i in `cat input_file`&lt;BR /&gt;do&lt;BR /&gt;find /dir_where_to_find -name $i &lt;BR /&gt;if [$? -eq 0]&lt;BR /&gt;then&lt;BR /&gt;echo $i &amp;gt;&amp;gt; /tmp/found_files.txt&lt;BR /&gt;else&lt;BR /&gt;echo $i &amp;gt;&amp;gt; /tmp/file_not_found.txt&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Dec 2003 11:51:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140090#M155119</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2003-12-09T11:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: find script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140091#M155120</link>
      <description>Hi RAC,&lt;BR /&gt;&lt;BR /&gt;Thanks for the info, we have used that but what if we dont no the search directory? How would do a global search, if the file is found then the output to be redirected to log file saying ie. "$file found in directory_name"?</description>
      <pubDate>Tue, 09 Dec 2003 12:01:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140091#M155120</guid>
      <dc:creator>Edgar_8</dc:creator>
      <dc:date>2003-12-09T12:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: find script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140092#M155121</link>
      <description>Say you have a list of files to be found in file input file.&lt;BR /&gt;&lt;BR /&gt;for i in `cat input_file`&lt;BR /&gt;do&lt;BR /&gt;find / -depth -name $i -print -exec echo {} &amp;gt;&amp;gt; /tmp/files.txt&lt;BR /&gt;if [$? -eq 0]&lt;BR /&gt;then&lt;BR /&gt;echo $i &amp;gt;&amp;gt; /tmp/found_files.txt&lt;BR /&gt;else&lt;BR /&gt;echo $i &amp;gt;&amp;gt; /tmp/file_not_found.txt&lt;BR /&gt;fi</description>
      <pubDate>Tue, 09 Dec 2003 12:09:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140092#M155121</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2003-12-09T12:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: find script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140093#M155122</link>
      <description>modified:&lt;BR /&gt;  &lt;BR /&gt;for i in `cat input_file`&lt;BR /&gt;do&lt;BR /&gt;find / -name $i &amp;gt;&amp;gt; /tmp/found_files.txt&lt;BR /&gt;if [$? -ne 0]&lt;BR /&gt;echo $i &amp;gt;&amp;gt; /tmp/file_not_found.txt&lt;BR /&gt;fi&lt;BR /&gt; &lt;BR /&gt;found_files will contain full pathname &amp;amp; filename.&lt;BR /&gt; &lt;BR /&gt;regards,&lt;BR /&gt;Thierry.</description>
      <pubDate>Tue, 09 Dec 2003 12:09:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140093#M155122</guid>
      <dc:creator>Thierry Poels_1</dc:creator>
      <dc:date>2003-12-09T12:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: find script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140094#M155123</link>
      <description>Based on RAC's submission, to search globally and log where found do:&lt;BR /&gt;&lt;BR /&gt;for i in `cat input_file`&lt;BR /&gt;do&lt;BR /&gt;  find / -name "$i" &amp;gt; /tmp/found_files.tmp&lt;BR /&gt;  if [$? -eq 0]&lt;BR /&gt;  then&lt;BR /&gt;    echo "FOUND:$i"&lt;BR /&gt;    cat /tmp/found_files.tmp&lt;BR /&gt;  else&lt;BR /&gt;    echo "FAILED TO FIND:$i"&lt;BR /&gt;  fi&lt;BR /&gt;done &amp;gt;&amp;gt; /tmp/results.txt&lt;BR /&gt;&lt;BR /&gt;Strictly, if run with privilege, e.g. as root, you should avoid predictable names in shared directories in case some malicious person creatred /tmp/results.txt as a symbolic link to something important, e.g. /etc/fstab</description>
      <pubDate>Tue, 09 Dec 2003 12:11:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140094#M155123</guid>
      <dc:creator>Alan Turner</dc:creator>
      <dc:date>2003-12-09T12:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: find script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140095#M155124</link>
      <description>How about in perl. This uses "ls -1R" to generate list of all filenames. It goes through the file system once and generates a list of all directories the filename is located.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl &lt;BR /&gt;$startdir="/";&lt;BR /&gt;open(INP,"&lt;YOURFILELIST&gt;&lt;/YOURFILELIST&gt;while(&lt;INP&gt;) { chomp; $names{$_}=[]; }&lt;BR /&gt;close(INP);&lt;BR /&gt;$lastdir=$startdir;&lt;BR /&gt;open(LS,"ls -1R $startdir|");&lt;BR /&gt;while(&lt;LS&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;next unless $_;&lt;BR /&gt;if (substr($_,0,1) eq "/") { $lastdir=$_; }&lt;BR /&gt;else {&lt;BR /&gt;push(@{$names{$_}},$lastdir) if $names{$_};&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;close(LS);&lt;BR /&gt;foreach $name (sort keys %names) {&lt;BR /&gt; $dirs=$names{$name};&lt;BR /&gt; if (scalar @$dirs) {&lt;BR /&gt;  print $name," ",join(",",@$dirs),"\n";&lt;BR /&gt; } else {&lt;BR /&gt;  print $name," NOT FOUND...\n";&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt; &lt;BR /&gt;HTH&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills&lt;/LS&gt;&lt;/INP&gt;</description>
      <pubDate>Tue, 09 Dec 2003 13:45:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/find-script/m-p/3140095#M155124</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-12-09T13:45:33Z</dc:date>
    </item>
  </channel>
</rss>

