Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using find, excluding directories  RSS feed

 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Directory TEST has sub-directories dir1, dir2, dir3 .... dir 100

When I use the following command
find TEST -print
will display dir1 , dir2, dir3 ... dir100 and all files below these directories.

When using the command
find TEST -name dir1 -print
will display dir1 and all files below this directory.

Is there a find command that will display all directories except dir1?
I appreciate any info anyone can give on this. Thanks in advance.

Rob
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably depends on the OS and the particular implementation of find.

You might try something like:



Guy
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Hunter wrote:
find TEST -name dir1 -print
will display dir1 and all files below this directory.

Is there a find command that will display all directories except dir1?

It doesn't print files below dir1 in my case (Linux/ find (GNU findutils) 4.4.0).

However, I would try a 'not'


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!