Looking for Files with Particular Names

You can look for particular files by using a regular expression with metacharacters (shell wildcards, not grep-like expressions ()) as an argument to the -name operator. Because the shell also understands these metacharacters, it is necessary to quote () them so they are passed to find unchanged. Any kind of quoting can be used:

% find . -name \*.o -print % find . -name '*.o' -print % find . -name "[a-zA-Z]*.o" -print

Any directory along the path to the file is not matched with the -name operator, merely the name at the end of the path. For example, the commands above would not match the pathname /subdir.o/afile-but they would match /subdir.o and /src/subdir/prog.o.

csh_init
sh_init
Article shows a way to match directories in the middle of a path. [Here's a "find file" alias:


alias ff "find . -name '*\!{*}*' -ls"

Give it a file or directory name; the alias will give a long listing of any file or directory names that contain the argument. For example:

% ff makedirs 415863 3 -rw-r--r-- 1 359 daemon 2072 Feb 19 1994 ./adir/makedirs.sh

Very handy. -JP ]

- BB