LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2015, 01:05 PM   #1
greatbear
Member
 
Registered: Feb 2012
Distribution: ubuntu
Posts: 44

Rep: Reputation: Disabled
find command fear and loathing


Its plentiful documentation fails to explain how to use it. After googling all over the world and hunting down examples, it turns out they don't work as the man page indicates if you alter them in the slightest. In fact I know what I want to find, where it is, how to describe it; but the problem is getting find to list that file or those files and moreover making sense of its horrid documentation. It lists too many things. It ignores -prune. It either does nothing or too much. Its a horrible, horrible program, and you are expected to make up the difference by experimentation.

Its so complicated as to make it more worthwhile just to list every file and filter them out with other utilities. Honestly, why go through so much trouble to learn about a command that is as obfuscated as a heartpump?

Sure its great for listing all the files and directories in one subdir, but if you want to exclude multiple dirs or files forget it. Pipe it through grep.
 
Old 01-16-2015, 06:48 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Enoquestion
 
Old 01-16-2015, 07:21 AM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,289

Rep: Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322Reputation: 2322
Yů're right. I find the -path option broken - sad but true.

Use it this way:
From search top dir <find -name '*name*'> and both asterisks may not be necessary
For case insensitive <find -iname '*name*'>

or for file type
<find -type l' all the types work.

The atime & ctime also leave me desiring accommodation in a home for the bewildered. Continuing the good tradition of pppd, vim, emacs and such worth candidates for a total rewrite.
 
Old 01-16-2015, 07:53 AM   #4
J Martin Rushton
Member
 
Registered: Jan 2015
Location: England
Distribution: Mainly CentOS
Posts: 31

Rep: Reputation: Disabled
Running on CentOS 6:
Code:
# find /usr -path find
# find /usr -path \*find
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/generic/find
/usr/src/kernels/2.6.32-358.el6.x86_64/include/config/generic/find
/usr/bin/oldfind
/usr/bin/find
/usr/bin/gnatfind
/usr/bin/gst-typefind
which is exactly as documented.

Code:
# find /usr/* -prune
/usr/bin
/usr/etc
/usr/games
/usr/include
/usr/lib
/usr/lib64
/usr/libexec
/usr/local
/usr/lpp
/usr/sbin
/usr/share
/usr/src
/usr/tmp
These are all directories (except tmp which is a link), so find does not descend into them, exactly as documented.

-{a,c,m}time can be a bit of fun, consider using -daystart to force the interpretation of time to run from 00:00:00 today. -daystart -mtime +1 is then always earlier than yesterday.

As regards to listing all files and filtering them, find will be more efficient and do it with less image activations. Not a problem for a few hundred files, but significant for a few hundred thousand.

Like many venerable programs the syntax can be a bit funny, but then it tries to accommodate various historic flavours of UNIX as well as modern Linux systems. ps is another fundamental program that suffers from the same option bloat. In practice I find you end up knowing the half dozen or so options you use and ignoring the rest until you stumble across them in a script.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Fear & Loathing At 3 AM LXer Syndicated Linux News 0 12-16-2014 02:12 PM
LXer: Fear and loathing in Holland LXer Syndicated Linux News 0 03-15-2009 05:40 AM
fear and loathing with solaris fancylad Solaris / OpenSolaris 23 06-04-2008 03:28 PM
Apple is Worried? (Fear and Loathing in Cupertino) rickh General 3 05-18-2007 05:51 PM
LXer: Fear And Loathing In Googlemania LXer Syndicated Linux News 0 04-27-2006 04:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration