LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 05-03-2015, 05:16 PM   #1
johnywhy
LQ Newbie
 
Registered: Aug 2011
Posts: 27

Rep: Reputation: Disabled
Understanding FIND


hi

hope this is the right place for noob questions

i'm struggling with this example:

Code:
$ find . -name temp -prune -o -print
from theunixschool.com
it means:
Find all the files except the ones under the temp directory.

shouldn't it be:
Code:
$ find . -path temp -prune -o -print
thx!
 
Old 05-03-2015, 06:37 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,253

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
the command is correct -name specifies the name to prune, the prune option is awkward and counter intuative and you don't see it used much, best to experiment with it to see how it works also read the man page for find, it's only slightly confusing
 
Old 05-03-2015, 06:47 PM   #3
johnywhy
LQ Newbie
 
Registered: Aug 2011
Posts: 27

Original Poster
Rep: Reputation: Disabled
thx for reply!

so you're saying it means: "prune a directory named temp".

correct?

then how would you prune files named 'temp'?

Quote:
Originally Posted by Keith Hedger View Post
the prune option is awkward and counter intuative and you don't see it used much
glad to know i'm not the only one who finds it counter-intuitive! what is a less awkward method?

thx!
 
Old 05-03-2015, 06:58 PM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,253

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
if you dont want certain files then you can use an expression like so
Code:
find /etc/dpkg -not -iname  "debian"
this will find all files except those named debian, using -iname the expression is case insensitive.
you can of course pipe the out put to another command for further processing.
 
Old 05-03-2015, 06:59 PM   #5
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,253

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
as to your second part of the question i find piping the output of find to grep or sed gives much finer control of the output
 
  


Reply

Tags
cli, find


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Understanding find manpage sporty Linux - Newbie 2 07-27-2006 02:39 PM
help understanding ln dr_zayus69 Linux - General 3 01-14-2005 09:33 PM
A better understanding! nny0000 Slackware 1 04-14-2004 01:01 PM
Understanding X?? ++ bdp Linux - General 2 02-25-2004 06:47 PM
Understanding df -k itsjustme Linux - General 6 10-28-2003 01:08 PM


All times are GMT -5. The time now is 10:30 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration