02-03-2020
I guess you have a wrong perception how the pruning works.?
-prune stops descending directories at the current point.
When it is preceded by a condition that becomes true for a directory, then that directory will be skipped.
When it is preceded by a condition that becomes true for a file, then the file and following files will not be excluded, only further directories in that directory will be skipped.
Last edited by MadeInGermany; 02-03-2020 at 10:01 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a directory named https-abcd
Under that I have some directories, files and links.
One of those directories is with name logs and the logs directory has lot of files in it.
I need to tar the whole https-abcd directory excluding the logs directory only, I should get all the links, files and... (2 Replies)
Discussion started by: venu_nbk
2 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I am using a find command like below in my script:
find /outfiles -type f -name cat -o -name vi -o -name grep 2>/dev/null
Which will search for files like "cat" , "vi" or "grep" in the "/outfiles" and subdirectories.
I want to ignore a particular subdirectory from the search. I... (4 Replies)
Discussion started by: deepakgang
4 Replies
3. UNIX for Dummies Questions & Answers
Hi all;
I'm having a problem when want to list a large number of files in current directory using find together with the prune option.
First i used this command but it list all the files including those in sub directories:
find . -name "*.dat" | xargs ls -ltr
Then i modified the command... (2 Replies)
Discussion started by: ashikin_8119
2 Replies
4. Shell Programming and Scripting
Hi,
I want to list files only from the current dir and its child dir (not from child's child dir).
i have the following files,
./ABC/1.log
./ABC/2.log
./ABC/ABC1/A.log
./ABC/ABC1/B.log
./ABC/ABC1/XYZ/A1.log
./ABC/ABC1/XYZ/A2.log
Here i want to list only the log file from current... (1 Reply)
Discussion started by: apsprabhu
1 Replies
5. Shell Programming and Scripting
OK, I'm trying search and destroy tabs again.
This time I'm having trouble excluding certain directories from my search.
Here is what I have tried and it is not ignoring the top level build directory:
find . -path ./build -prune -name \*.java -o -print | xargs grep -i ' '
I don't... (6 Replies)
Discussion started by: siegfried
6 Replies
6. Shell Programming and Scripting
Hi,
i try to catch all files in a dir ,without going down in subdir , which don't have file extension and older than 10 days for example:
my dir :
drwxr-xr-x 7 notes01 notes 4096 Mar 8 14:11 .
drwxr-xr-x 116 root system 4096 Mar 9 11:17 ..
-rw-r----- 1 notes01... (4 Replies)
Discussion started by: Nicol
4 Replies
7. UNIX for Dummies Questions & Answers
How do I run a find without is looking in ./Trash
gregg@gregg-desktop:/media/Audio$ find . -type f ! -name '*.jpg' -size 1M -print |head
find: `./.Trash-1000/expunged/2781324553/mp3-to-m4b-batch': Input/output error
find:... (0 Replies)
Discussion started by: glev2005
0 Replies
8. UNIX for Dummies Questions & Answers
Hi
I am trying to list all files in every subdirectory from a given location. However, I realise that 1 folder will have files that I am not interested in. This is using a .csh file to execute
I have tried different scripts but to no avail. My current incarnation is below. Would someone be... (4 Replies)
Discussion started by: wonderbison
4 Replies
9. Shell Programming and Scripting
I am trying to find all .rhosts files on some unix systems. I tried just -name ".rhosts" but we have a lot of really large NFS and MVFS systems that I do not want to crawl and I am having a hard time excluding them. I also need to scan more than just /root /home and /users, so I really need to scan... (1 Reply)
Discussion started by: nitrobass24
1 Replies
10. Shell Programming and Scripting
Hi,
I have two files under two separate directories as in:
find . -name test.sh
./test.sh
./abc/test.sh
I want my find to only look for the file test.sh that is under the current directory and not one under /abc
How do I use prune to achieve this? I am on AIX (3 Replies)
Discussion started by: swasid
3 Replies
LEARN ABOUT DEBIAN
file::find::object
File::Find::Object(3pm) User Contributed Perl Documentation File::Find::Object(3pm)
NAME
File::Find::Object - An object oriented File::Find replacement
SYNOPSIS
use File::Find::Object;
my $tree = File::Find::Object->new({}, @targets);
while (my $r = $tree->next()) {
print $r ."
";
}
DESCRIPTION
File::Find::Object does same job as File::Find but works like an object and with an iterator. As File::Find is not object oriented, one
cannot perform multiple searches in the same application. The second problem of File::Find is its file processing: after starting its main
loop, one cannot easilly wait for another event and so get the next result.
With File::Find::Object you can get the next file by calling the next() function, but setting a callback is still possible.
FUNCTIONS
new
my $ffo = File::Find::Object->new( { options }, @targets);
Create a new File::Find::Object object. @targets is the list of directories or files which the object should explore.
options
depth
Boolean - returns the directory content before the directory itself.
nocrossfs
Boolean - doesn't continue on filesystems different than the parent.
followlink
Boolean - follow symlinks when they point to a directory.
You can safely set this option to true as File::Find::Object does not follow the link if it detects a loop.
filter
Function reference - should point to a function returning TRUE or FALSE. This function is called with the filename to filter, if the
function return FALSE, the file is skipped.
callback
Function reference - should point to a function, which would be called each time a new file is returned. The function is called with
the current filename as an argument.
next
Returns the next file found by the File::Find::Object. It returns undef once the scan is completed.
item
Returns the current filename found by the File::Find::Object object, i.e: the last value returned by next().
next_obj
Like next() only returns the result as a convenient File::Find::Object::Result object. "$ff->next()" is equivalent to
"$ff->next_obj()->path()".
item_obj
Like item() only returns the result as a convenient File::Find::Object::Result object. "$ff->item()" is equivalent to
"$ff->item_obj()->path()".
$ff->set_traverse_to([@children])
Sets the children to traverse to from the current node. Useful for pruning items to traverse.
$ff->prune()
Prunes the current directory. Equivalent to $ff->set_traverse_to([]).
[@children] = $ff->get_traverse_to()
Retrieves the children that will be traversed to.
[@files] = $ff->get_current_node_files_list()
Gets all the files that appear in the current directory. This value is constant for every node, and is useful to use as the basis of the
argument for "set_traverse_to()".
BUGS
No bugs are known, but it doesn't mean there aren't any.
SEE ALSO
There's an article about this module in the Perl Advent Calendar of 2006: <http://perladvent.pm.org/2006/2/>.
File::Find is the core module for traversing files in perl, which has several limitations.
File::Next, File::Find::Iterator, File::Walker and the unmaintained File::FTS are alternatives to this module.
LICENSE
Copyright (C) 2005, 2006 by Olivier Thauvin
This package is free software; you can redistribute it and/or modify it under the following terms:
1. The GNU General Public License Version 2.0 - http://www.opensource.org/licenses/gpl-license.php
2. The Artistic License Version 2.0 - http://www.perlfoundation.org/legal/licenses/artistic-2_0.html
3. At your option - any later version of either or both of these licenses.
perl v5.10.0 2009-06-18 File::Find::Object(3pm)