Sponsored Content
Top Forums Shell Programming and Scripting Find Command Include Sub Directory Post 302935047 by Don Cragun on Thursday 12th of February 2015 01:05:01 PM
Old 02-12-2015
Quote:
Originally Posted by DGPickett
Trivial, but '-print' or '-exec ls {}' are usually unnecessary, as 'find' prints file names unless you tell it you want something else.

It might be easier to make a clone tree of the dirs you *do* want, once, and search in it. A clone tree can be built up using either symlinks to dirs or identically named dirs containing links to files. If you use sym links for files or dirs, the '-follow' is needed to make 'find' traverse them.
The -print is needed in this case because the directory names that have files under them pruned will be printed as part of the default case. Adding the explicit -print (or the MUCH less efficient and MUCH slower -exec ls {} \;) in the case where we want the pathnames printed will avoid printing those unwanted directory names.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using find command only in current directory

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)
Discussion started by: jliebling
5 Replies

2. Shell Programming and Scripting

include all files under a directory

I want to include all the subnet files under /etc/dhcpd/ to /etc/dhcpd.conf so here is my content of dhcpd.conf ... include "/etc/dhcpd/*"; however, the check-syntax reports syntax error, as they do not recognize the wildcard *, and display that " file /etc/dhcpd/* could not be found. ... (4 Replies)
Discussion started by: fredao
4 Replies

3. UNIX for Dummies Questions & Answers

how to find a file named vijay in a directory using find command

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)
Discussion started by: amirthraj_12
6 Replies

4. Shell Programming and Scripting

Find command, -name by directory and subdirectory?

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)
Discussion started by: makodarear
16 Replies

5. UNIX for Dummies Questions & Answers

find command to look for current directory only

i have this find command on my script as: for i in `find $vdir -name "$vfile" -mtime +$pday` the problem with this code is that the sub-directories are included on the search. how do i restrict the search to confine only on the current directory and ignore the sub-directories. please advise.... (7 Replies)
Discussion started by: wtolentino
7 Replies

6. Shell Programming and Scripting

making find/sed to include directory names with spaces

how can i make find/sed to include directory names with spaces the command is like this for i in `find wp-content/themes -type f -print0 | xargs -0 grep -l -iE 'e'`;do sed -i -e 's/word1/word2/gI' "$i";done but it skips one directory names with spaces sed: can't read ./Nova: No such... (5 Replies)
Discussion started by: vanessafan99
5 Replies

7. Shell Programming and Scripting

Find command with ignore directory

Dear All, I am using find command find /my_rep/*/RKYPROOF/*/*/WDM/HOME_INT/PWD_DATA -name rk*myguidelines*.pdf -print The problem i am facing here is find /my_rep/*/ the directory after my_rep could be mice001, mice002 and mice001_PO, mice002_PO i want to ignore mice***_PO directory... (3 Replies)
Discussion started by: yadavricky
3 Replies

8. Shell Programming and Scripting

How to include file pattern in find command?

Hi I've to remove the files which has the following file pattern in path /home/etc/logs fnm_HST_date1 fnm_hst_date1 fnm_HST_date2 I've used the following code to to remove the files having file names like "HST" . #!/usr/bin/ksh set -x file_path=/home/etc/logs file_nm=HST find... (2 Replies)
Discussion started by: smile689
2 Replies

9. Shell Programming and Scripting

Find out directory where command is located

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)
Discussion started by: SkySmart
5 Replies

10. Shell Programming and Scripting

How-To Exclude Directory in find command

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)
Discussion started by: mohtashims
7 Replies
ExtUtils::Manifest(3pm) 				 Perl Programmers Reference Guide				   ExtUtils::Manifest(3pm)

NAME
ExtUtils::Manifest - utilities to write and check a MANIFEST file SYNOPSIS
require ExtUtils::Manifest; ExtUtils::Manifest::mkmanifest; ExtUtils::Manifest::manicheck; ExtUtils::Manifest::filecheck; ExtUtils::Manifest::fullcheck; ExtUtils::Manifest::skipcheck; ExtUtils::Manifest::manifind(); ExtUtils::Manifest::maniread($file); ExtUtils::Manifest::manicopy($read,$target,$how); DESCRIPTION
mkmanifest() writes all files in and below the current directory to a file named in the global variable $ExtUtils::Manifest::MANIFEST (which defaults to "MANIFEST") in the current directory. It works similar to find . -print but in doing so checks each line in an existing "MANIFEST" file and includes any comments that are found in the existing "MANIFEST" file in the new one. Anything between white space and an end of line within a "MANIFEST" file is considered to be a comment. Filenames and comments are separated by one or more TAB characters in the output. All files that match any regular expression in a file "MANIFEST.SKIP" (if such a file exists) are ignored. manicheck() checks if all the files within a "MANIFEST" in the current directory really do exist. If "MANIFEST" and the tree below the cur- rent directory are in sync it exits silently, returning an empty list. Otherwise it returns a list of files which are listed in the "MANI- FEST" but missing from the directory, and by default also outputs these names to STDERR. filecheck() finds files below the current directory that are not mentioned in the "MANIFEST" file. An optional file "MANIFEST.SKIP" will be consulted. Any file matching a regular expression in such a file will not be reported as missing in the "MANIFEST" file. The list of any extraneous files found is returned, and by default also reported to STDERR. fullcheck() does both a manicheck() and a filecheck(), returning references to two arrays, the first for files manicheck() found to be missing, the seond for unexpeced files found by filecheck(). skipcheck() lists all the files that are skipped due to your "MANIFEST.SKIP" file. manifind() returns a hash reference. The keys of the hash are the files found below the current directory. maniread($file) reads a named "MANIFEST" file (defaults to "MANIFEST" in the current directory) and returns a HASH reference with files being the keys and comments being the values of the HASH. Blank lines and lines which start with "#" in the "MANIFEST" file are discarded. "manicopy($read,$target,$how)" copies the files that are the keys in the HASH %$read to the named target directory. The HASH reference $read is typically returned by the maniread() function. This function is useful for producing a directory tree identical to the intended distribution tree. The third parameter $how can be used to specify a different methods of "copying". Valid values are "cp", which actually copies the files, "ln" which creates hard links, and "best" which mostly links the files but copies any symbolic link to make a tree with- out any symbolic link. Best is the default. MANIFEST.SKIP The file MANIFEST.SKIP may contain regular expressions of files that should be ignored by mkmanifest() and filecheck(). The regular expres- sions should appear one on each line. Blank lines and lines which start with "#" are skipped. Use "#" if you need a regular expression to start with a sharp character. A typical example: # Version control files and dirs. RCS CVS ,v$ # Makemaker generated files and dirs. ^MANIFEST. ^Makefile$ ^blib/ ^MakeMaker-d # Temp, old and emacs backup files. ~$ .old$ ^#.*#$ ^.# If no MANIFEST.SKIP file is found, a default set of skips will be used, similar to the example above. If you want nothing skipped, simply make an empty MANIFEST.SKIP file. EXPORT_OK &mkmanifest, &manicheck, &filecheck, &fullcheck, &maniread, and &manicopy are exportable. GLOBAL VARIABLES
$ExtUtils::Manifest::MANIFEST defaults to "MANIFEST". Changing it results in both a different "MANIFEST" and a different "MANIFEST.SKIP" file. This is useful if you want to maintain different distributions for different audiences (say a user version and a developer version including RCS). $ExtUtils::Manifest::Quiet defaults to 0. If set to a true value, all functions act silently. $ExtUtils::Manifest::Debug defaults to 0. If set to a true value, or if PERL_MM_MANIFEST_DEBUG is true, debugging output will be produced. DIAGNOSTICS
All diagnostic output is sent to "STDERR". "Not in MANIFEST:" file is reported if a file is found which is not in "MANIFEST". "Skipping" file is reported if a file is skipped due to an entry in "MANIFEST.SKIP". "No such file:" file is reported if a file mentioned in a "MANIFEST" file does not exist. "MANIFEST:" $! is reported if "MANIFEST" could not be opened. "Added to MANIFEST:" file is reported by mkmanifest() if $Verbose is set and a file is added to MANIFEST. $Verbose is set to 1 by default. ENVIRONMENT
PERL_MM_MANIFEST_DEBUG Turns on debugging SEE ALSO
ExtUtils::MakeMaker which has handy targets for most of the functionality. AUTHOR
Andreas Koenig <andreas.koenig@anima.de> perl v5.8.0 2002-06-01 ExtUtils::Manifest(3pm)
All times are GMT -4. The time now is 09:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy