LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 05-03-2015, 04:16 PM   #1
johnywhy
Member
 
Registered: Aug 2011
Posts: 34

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, 05:37 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
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, 05:47 PM   #3
johnywhy
Member
 
Registered: Aug 2011
Posts: 34

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, 05:58 PM   #4
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
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, 05:59 PM   #5
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
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



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

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

All times are GMT -5. The time now is 08:18 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