<?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: Keep find within a single directory in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696968#M103231</link>
    <description>i always use the 'depth' parameter for this instead of prune.</description>
    <pubDate>Fri, 23 Dec 2005 04:11:31 GMT</pubDate>
    <dc:creator>dirk dierickx</dc:creator>
    <dc:date>2005-12-23T04:11:31Z</dc:date>
    <item>
      <title>Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696960#M103223</link>
      <description>My grep commands were working find until the number of files in the search directory exceeded the parameter size.&lt;BR /&gt;&lt;BR /&gt;All the solution I find say to use find then pipe or -xargs the find output to grep -l -E &lt;CONTENT&gt;.&lt;BR /&gt;&lt;BR /&gt;That does work, but it has two problems.&lt;BR /&gt;&lt;BR /&gt;First, it returns ./&lt;FILENAME&gt; instead of just &lt;FILENAME&gt;.  That's fixable by messing with the output.&lt;BR /&gt;&lt;BR /&gt;But second and worse, find wants to drill down to lower subdirectories.  I only want to return files from the single directory where I'm searching.&lt;BR /&gt;&lt;BR /&gt;I've tried the -prune and -xdev options for find, but none effectively stop the subdirectories from being included in the search.&lt;BR /&gt;&lt;BR /&gt;Is there any way to keep find in a single directory, or an alternative to using find to fix the original grep "paramter list too long" problem?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Jim&lt;/FILENAME&gt;&lt;/FILENAME&gt;&lt;/CONTENT&gt;</description>
      <pubDate>Thu, 22 Dec 2005 12:26:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696960#M103223</guid>
      <dc:creator>jdavee</dc:creator>
      <dc:date>2005-12-22T12:26:57Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696961#M103224</link>
      <description>I think -prune is the option you want on find.&lt;BR /&gt;&lt;BR /&gt;Another option would be to put your file list in a variable (could be read in from a file or from output of an ls command of some sort) and do a for loop that would grep each file individually.</description>
      <pubDate>Thu, 22 Dec 2005 12:34:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696961#M103224</guid>
      <dc:creator>Jeff_Traigle</dc:creator>
      <dc:date>2005-12-22T12:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696962#M103225</link>
      <description>how about using :&lt;BR /&gt;&lt;BR /&gt;ll | grep "^\-"| awk '{print $NF}' | xargs&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Dec 2005 12:35:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696962#M103225</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2005-12-22T12:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696963#M103226</link>
      <description>I'll confirm:  prune is what you want.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete</description>
      <pubDate>Thu, 22 Dec 2005 12:38:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696963#M103226</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2005-12-22T12:38:04Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696964#M103227</link>
      <description>Hi Jim:&lt;BR /&gt;&lt;BR /&gt;The key is to leverage both the '-path' and the '-prune' options of 'find':&lt;BR /&gt;&lt;BR /&gt;# find /home/jrf -path "/home/jrf/*" -prune -type f -exec grep "ARY" /dev/null {} \;&lt;BR /&gt;&lt;BR /&gt;...would search for files in '/home/jrf' without descent into subdirectories, and 'grep' for the pattern "ARY".  All occurances found would be printed with the filename in front.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 22 Dec 2005 12:46:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696964#M103227</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-12-22T12:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696965#M103228</link>
      <description>Thanks everyone for the prompt replies!&lt;BR /&gt;&lt;BR /&gt;The -prune and -path options did the trick to restrict the find command to the current directory:&lt;BR /&gt;&lt;BR /&gt;cd &lt;DIR&gt;&lt;BR /&gt;find . -path "./*" | xargs grep -l -E &lt;CONTENTS&gt;&lt;BR /&gt;&lt;BR /&gt;I'll also try the ls suggestion.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Jim&lt;/CONTENTS&gt;&lt;/DIR&gt;</description>
      <pubDate>Thu, 22 Dec 2005 12:59:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696965#M103228</guid>
      <dc:creator>jdavee</dc:creator>
      <dc:date>2005-12-22T12:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696966#M103229</link>
      <description>I have always said that anybody who knows and understands all the arguments to find and can use them in anger has achieved minor guru status in the Unix world. ;-)</description>
      <pubDate>Thu, 22 Dec 2005 22:32:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696966#M103229</guid>
      <dc:creator>Daavid Turnbull</dc:creator>
      <dc:date>2005-12-22T22:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696967#M103230</link>
      <description>You can get the files in the current directoy as,&lt;BR /&gt;&lt;BR /&gt;# ls -l | awk '/^-/ { print $9; }'&lt;BR /&gt;&lt;BR /&gt;To grep into the file with find command then use syntax as,&lt;BR /&gt;&lt;BR /&gt;# find &lt;DIRECTORY&gt; -type f -grep 'pattern' {} \+&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;# find &lt;DIRECTORY&gt; -type f | xargs grep 'pattern'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;There is another problem in your requiremnet. Grep will create messy messages when grepping with binary file??&lt;BR /&gt;&lt;BR /&gt;You can remove that with file option as,&lt;BR /&gt;&lt;BR /&gt;for file `find &lt;SYNTAX&gt;`&lt;BR /&gt;do&lt;BR /&gt;   file $file | grep -q 'executable'&lt;BR /&gt;   if [[ $? -ne 0 ]]&lt;BR /&gt;   then&lt;BR /&gt;      grep 'pattern' ${file}&lt;BR /&gt;   fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;-Muthu&lt;BR /&gt;&lt;/SYNTAX&gt;&lt;/DIRECTORY&gt;&lt;/DIRECTORY&gt;</description>
      <pubDate>Fri, 23 Dec 2005 02:55:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696967#M103230</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-12-23T02:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696968#M103231</link>
      <description>i always use the 'depth' parameter for this instead of prune.</description>
      <pubDate>Fri, 23 Dec 2005 04:11:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696968#M103231</guid>
      <dc:creator>dirk dierickx</dc:creator>
      <dc:date>2005-12-23T04:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Keep find within a single directory</title>
      <link>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696969#M103232</link>
      <description>Followup:&lt;BR /&gt;&lt;BR /&gt;The first ls suggestion didn't work well, but the find suggested by James Ferguson got implemented in my app easily.&lt;BR /&gt;&lt;BR /&gt;The app itself is a Java UI running on a Windows server that connects to HP-UX data via CIFS.  Searches over the CIFS connection for files with specific content were simply impossible using any Windows search tool (and we tried almost a dozen), so my Java app constructs a short Unix script, sends it to the HP-UX server, executes it, collects the results (they were piped to a file), and reformats into a simple Java grid table for file name, date, size, path, etc.&lt;BR /&gt;&lt;BR /&gt;It now works with larger directory sizes thanks to using the find command.&lt;BR /&gt;&lt;BR /&gt;Thanks again to everyone for the prompt replies plus options in case one didn't work!&lt;BR /&gt;&lt;BR /&gt;Jim</description>
      <pubDate>Tue, 27 Dec 2005 01:01:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/keep-find-within-a-single-directory/m-p/3696969#M103232</guid>
      <dc:creator>jdavee</dc:creator>
      <dc:date>2005-12-27T01:01:34Z</dc:date>
    </item>
  </channel>
</rss>

