Date: Mon, 19 May 2008 12:40:46 +0200 From: Jonathan McKeown <jonathan@hst.org.za> To: freebsd-questions@freebsd.org Subject: Re: Now what would you expect this to print out? Message-ID: <200805191240.47144.jonathan@hst.org.za> In-Reply-To: <20080519094603.GC12033@osiris.chen.org.nz> References: <7d6fde3d0805190149y7a3bfa75j2ca6a67cef66e8f6@mail.gmail.com> <20080519094603.GC12033@osiris.chen.org.nz>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 19 May 2008 11:46, Jonathan Chen wrote: > On Mon, May 19, 2008 at 01:49:35AM -0700, Garrett Cooper wrote: > > Riddle for the day for folks that have source trees... what would you > > expect this to print out (ask yourself the question and then execute the > > command)? > > > > find /usr/src -name Makefile -or -name '*.mk' -print > > > > The expected output and what actual output differed in my mind, but maybe > > somebody else can "shed some light" on the logic behind what happened > > It's a problem that catches many young players with find(1). One has > to remember from reading the man-page that all directives have an > implicit AND operator on it; and that includes the "-print" directive. > So to get what you want, you have to introduce brackets: > > find /usr/src \( -name Makefile -or -name '*.mk' \) -print Or, slightly bizarrely, just leave the -print off altogether - as the manpage says, If none of -exec, -ls, -print0, or -ok is specified, the given expression shall be effectively replaced by ( given expression ) -print. [Note the parens around given expression] I forget where I saw this quote first, but the last five words always make me think of the find command: Real Programmers consider "what you see is what you get" to be just as bad a concept in Text Editors as it is in women. No, the Real Programmer wants a "you asked for it, you got it" text editor - complicated, cryptic, powerful, unforgiving, dangerous. Jonathan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805191240.47144.jonathan>