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
git-ls-tree
GIT-LS-TREE(1) Git Manual GIT-LS-TREE(1)NAME
git-ls-tree - List the contents of a tree object
SYNOPSIS
git ls-tree [-d] [-r] [-t] [-l] [-z]
[--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]]
<tree-ish> [<path>...]
DESCRIPTION
Lists the contents of a given tree object, like what "/bin/ls -a" does in the current working directory. Note that:
o the behaviour is slightly different from that of "/bin/ls" in that the <path> denotes just a list of patterns to match, e.g. so
specifying directory name (without -r) will behave differently, and order of the arguments does not matter.
o the behaviour is similar to that of "/bin/ls" in that the <path> is taken as relative to the current working directory. E.g. when you
are in a directory sub that has a directory dir, you can run git ls-tree -r HEAD dir to list the contents of the tree (that is sub/dir
in HEAD). You don't want to give a tree that is not at the root level (e.g. git ls-tree -r HEAD:sub dir) in this case, as that would
result in asking for sub/sub/dir in the HEAD commit. However, the current working directory can be ignored by passing --full-tree
option.
OPTIONS
<tree-ish>
Id of a tree-ish.
-d
Show only the named tree entry itself, not its children.
-r
Recurse into sub-trees.
-t
Show tree entries even when going to recurse them. Has no effect if -r was not passed. -d implies -t.
-l, --long
Show object size of blob (file) entries.
-z
line termination on output.
--name-only, --name-status
List only filenames (instead of the "long" output), one per line.
--abbrev[=<n>]
Instead of showing the full 40-byte hexadecimal object lines, show only a partial prefix. Non default number of digits can be specified
with --abbrev=<n>.
--full-name
Instead of showing the path names relative to the current working directory, show the full path names.
--full-tree
Do not limit the listing to the current working directory. Implies --full-name.
[<path>...]
When paths are given, show them (note that this isn't really raw pathnames, but rather a list of patterns to match). Otherwise
implicitly uses the root level of the tree as the sole path argument.
OUTPUT FORMAT
<mode> SP <type> SP <object> TAB <file>
Unless the -z option is used, TAB, LF, and backslash characters in pathnames are represented as ,
, and \, respectively. This output
format is compatible with what --index-info --stdin of git update-index expects.
When the -l option is used, format changes to
<mode> SP <type> SP <object> SP <object size> TAB <file>
Object size identified by <object> is given in bytes, and right-justified with minimum width of 7 characters. Object size is given only for
blobs (file) entries; for other entries - character is used in place of size.
GIT
Part of the git(1) suite
Git 1.7.10.4 11/24/2012 GIT-LS-TREE(1)