Add a not (!) to the find command to exclude that directory.
i.e.
That will exclude the directory itself, but not the tree beneath it; find will still descend into its contents and generate output. To prevent that, a -prune is required.
Further, since -name only looks at the basename, -name cannot match an absolute pathname. There could be many instances of dir2 within /dir/path.
A POSIX-compliant invocation will need to use -exec to call test/[ to check the full pathname (via {}). However, a few finds support a -path which can do the job more efficiently.
I am trying to use the find command to find files in the current directory that meet a certain date criteria.
find . -type -f -mtime +2
However, the above also checks the directories below.
I tried -prune, but that seems to ignore this directory completely.
I read about using -path w/... (5 Replies)
I need to find whether there is a file named vijay is there or not in folder named "opt" .I tried "ls *|grep vijay" but it showed permission problem.
so i need to use find command (6 Replies)
Hi All,
I'm trying to use the find command to return matches for a directory and file.
For example, given the following directories:
/one/two/three/file1.txt
/one/three/two/file1.txt
/one/four/two/three/file1.txt
I'm expecting the following to be returned:
... (16 Replies)
Hello,
I know find can be prevented from recursing into directories with something like the following...
find . -name .svn -prune -a type d
But how can I completely prevent directories of a certain name (.svn) from being displayed at all, the top level and the children?
I really... (2 Replies)
i am trying to recursively save a remote FTP server but exclude the files immediately under a directory directory1
wget -r -N ftp://user:pass@hostname/directory1
I want to keep these which may have more files under them
directory1/dir1/file.jpg
directory1/dir2/file.jpg... (16 Replies)
This script writes the output files to FILES but I don't want to exclude all directories from ABC_CHQ and LYS_ADV, I want to include one sub directory name process which is under ABC_CHQ and LYS_ADV in the search. Right now its excluding everything from prune directories such as ABC_CHQ, LYS_ADV... (10 Replies)
so i have a script that i do not want copies of that script to be roaming around. i want that script to be in only one location on the filesystem, and whoever wants to use it should just link to it.
any idea on how to exit from a script if it is detected that the running version is a copy and... (5 Replies)
How can i tweak the below find command to exclude directory/s -> "/tmp/logs"
find . -type f \( ! -name "*.log*" ! -name "*.jar*" \) -printNote: -path option/argument does not work with the version of find that i have.
bash-3.2$ uname -a
SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v (7 Replies)
Hi,
I am using following command to find a specific file.
find . -name "find*.txt" -type f -print
I am issuing that command at root directory since I don't know in which sub folder that file is getting created from some other process.
As I am not having access to all directories, my... (3 Replies)
I am using aix. I would like to ignore the /u directory. I tried this but it is not working.
find / -type f -type d \( -path /u \) -prune -o -name '*rpm*' 2>/dev/null
/u/appx/ls.rpm
/u/arch/vim.rpm (4 Replies)
Discussion started by: cokedude
4 Replies
LEARN ABOUT DEBIAN
any::template::processdir
Any::Template::ProcessDir(3pm) User Contributed Perl Documentation Any::Template::ProcessDir(3pm)NAME
Any::Template::ProcessDir -- Process a directory of templates
VERSION
version 0.07
SYNOPSIS
use Any::Template::ProcessDir;
# Process templates and generate result files in a single directory
#
my $pd = Any::Template::ProcessDir->new(
dir => '/path/to/dir',
process_text => sub {
my $template = Any::Template->new( Backend => '...', String => $_[0] );
$template->process({ ... });
}
);
$pd->process_dir();
# Process templates and generate result files to a separate directory
#
my $pd = Any::Template::ProcessDir->new(
source_dir => '/path/to/source/dir',
dest_dir => '/path/to/dest/dir',
process_file => sub {
my $file = $_[0];
# do something with $file, return content
}
);
$pd->process_dir();
DESCRIPTION
Recursively processes a directory of templates, generating a set of result files in the same directory or in a parallel directory. Each
file in the source directory may be template-processed, copied, or ignored depending on its pathname.
CONSTRUCTOR
Specifying directory/directories
o If you want to generate the result files in the same directory as the templates, just specify dir.
my $pd = Any::Template::ProcessDir->new(
dir => '/path/to/dir',
...
);
o If you want to generate the result files in a separate directory from the templates, specify source_dir and dest_dir.
my $pd = Any::Template::ProcessDir->new(
source_dir => '/path/to/source/dir',
source_dir => '/path/to/dest/dir',
...
);
Specifying how to process templates
process_file
A code reference that takes the full template filename and the "Any::Template::ProcessDir" object as arguments, and returns the result
string. This can use Any::Template or another method altogether. By default it calls "process_text" on the contents of the file.
process_text
A code reference that takes the template text and the "Any::Template::ProcessDir" object as arguments, and returns the result string.
This can use Any::Template or another method altogether.
Optional parameters
dir_create_mode
Permissions mode to use when creating destination directories. Defaults to 0775. No effect if you are using a single directory.
file_create_mode
Permissions mode to use when creating destination files. Defaults to 0444 (read-only), so that destination files are not accidentally
edited.
ignore_files
Coderef which takes a full pathname and returns true if the file should be ignored. By default, all files will be considered.
readme_filename
Name of a README file to generate in the destination directory - defaults to "README". No file will be generated if you pass undef or
if you are using a single directory.
template_file_suffix
Suffix of template files in source directory. Defaults to ".src". This will be removed from the destination file name.
Any file in the source directory that does not have this suffix (or "ignore_file_suffix") will simply be copied to the destination.
METHODS
process_dir
Process the directory. If using multiple directories, the destination directory will be removed completely and recreated, to eliminate
any old files from previous processing.
SEE ALSO
Any::Template
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Jonathan Swartz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.14.2 2012-05-14 Any::Template::ProcessDir(3pm)