JavaScript is required to for searching.
跳过导航链接
退出打印视图
手册页第 1 部分:用户命令     Oracle Solaris 11.1 Information Library (简体中文)
为本文档评分
search filter icon
search icon

文档信息

前言

简介

User Commands

acctcom(1)

adb(1)

addbib(1)

admin(1)

alias(1)

allocate(1)

amt(1)

appcert(1)

apptrace(1)

apropos(1)

ar(1)

arch(1)

as(1)

asa(1)

at(1)

atq(1)

atrm(1)

audioconvert(1)

audioctl(1)

audioplay(1)

audiorecord(1)

audiotest(1)

auths(1)

auto_ef(1)

awk(1)

banner(1)

basename(1)

basename(1B)

batch(1)

bc(1)

bdiff(1)

bfs(1)

bg(1)

biff(1B)

break(1)

builtin(1)

cal(1)

calendar(1)

case(1)

cat(1)

cd(1)

cdc(1)

cdrw(1)

chdir(1)

checkeq(1)

checknr(1)

chgrp(1)

chkey(1)

chmod(1)

chown(1)

chown(1B)

ckdate(1)

ckgid(1)

ckint(1)

ckitem(1)

ckkeywd(1)

ckpath(1)

ckrange(1)

ckstr(1)

cksum(1)

cktime(1)

ckuid(1)

ckyorn(1)

clear(1)

cmp(1)

col(1)

comb(1)

comm(1)

command(1)

compress(1)

continue(1)

cp(1)

cpio(1)

cpp(1)

cputrack(1)

crle(1)

crontab(1)

csh(1)

csplit(1)

ct(1C)

ctags(1)

ctrun(1)

ctstat(1)

ctwatch(1)

cu(1C)

cut(1)

date(1)

dc(1)

deallocate(1)

decrypt(1)

delta(1)

deroff(1)

df(1B)

dhcpinfo(1)

diff(1)

diff3(1)

diffmk(1)

digest(1)

digestp(1)

dircmp(1)

dirname(1)

dirs(1)

dis(1)

disown(1)

dispgid(1)

dispuid(1)

dos2unix(1)

dpost(1)

du(1)

du(1B)

dump(1)

dumpcs(1)

dumpkeys(1)

echo(1)

echo(1B)

ed(1)

edit(1)

egrep(1)

eject(1)

elfdump(1)

elfedit(1)

elffile(1)

elfsign(1)

elfwrap(1)

encrypt(1)

enhance(1)

env(1)

eqn(1)

errange(1)

errdate(1)

errgid(1)

errint(1)

erritem(1)

error(1)

errpath(1)

errstr(1)

errtime(1)

erruid(1)

erryorn(1)

eval(1)

ex(1)

exec(1)

exit(1)

expand(1)

export(1)

exportfs(1B)

expr(1)

expr(1B)

exstr(1)

factor(1)

false(1)

fastboot(1B)

fasthalt(1B)

fc(1)

fg(1)

fgrep(1)

file(1)

file(1B)

filebench(1)

filep(1)

filesync(1)

filofaxp(1)

find(1)

finger(1)

fmt(1)

fmtmsg(1)

fold(1)

for(1)

foreach(1)

franklinp(1)

from(1B)

ftp(1)

function(1)

gcore(1)

gencat(1)

geniconvtbl(1)

genmsg(1)

get(1)

getconf(1)

getfacl(1)

getlabel(1)

getopt(1)

getoptcvt(1)

getopts(1)

gettext(1)

gettxt(1)

getzonepath(1)

glob(1)

goto(1)

gprof(1)

grep(1)

groups(1)

groups(1B)

grpck(1B)

hash(1)

hashcheck(1)

hashmake(1)

hashstat(1)

head(1)

helpdate(1)

helpgid(1)

helpint(1)

helpitem(1)

helppath(1)

helprange(1)

helpstr(1)

helptime(1)

helpuid(1)

helpyorn(1)

hist(1)

history(1)

hostid(1)

hostname(1)

i386(1)

i486(1)

iconv(1)

if(1)

indxbib(1)

install(1B)

ipcrm(1)

ipcs(1)

isainfo(1)

isalist(1)

jobs(1)

join(1)

jsh(1)

kbd(1)

kdestroy(1)

keylogin(1)

keylogout(1)

kill(1)

kinit(1)

klist(1)

kmdb(1)

kmfcfg(1)

kpasswd(1)

krb5-config(1)

ksh(1)

ksh88(1)

ksh93(1)

ktutil(1)

kvno(1)

lari(1)

last(1)

lastcomm(1)

ld(1)

ldapadd(1)

ldapdelete(1)

ldaplist(1)

ldapmodify(1)

ldapmodrdn(1)

ldapsearch(1)

ldd(1)

ld.so.1(1)

let(1)

lex(1)

lgrpinfo(1)

limit(1)

line(1)

list_devices(1)

listusers(1)

llc2_autoconfig(1)

llc2_config(1)

llc2_stats(1)

ln(1)

ln(1B)

loadkeys(1)

locale(1)

localedef(1)

logger(1)

logger(1B)

login(1)

logname(1)

logout(1)

look(1)

lookbib(1)

lorder(1)

ls(1)

ls(1B)

m4(1)

mac(1)

mach(1)

machid(1)

madv.so.1(1)

mail(1)

Mail(1B)

mail(1B)

mailcompat(1)

mailp(1)

mailq(1)

mailstats(1)

mailx(1)

make(1S)

makekey(1)

man(1)

mconnect(1)

mcs(1)

mdb(1)

mesg(1)

mkdir(1)

mkmsgs(1)

mkstr(1B)

mktemp(1)

moe(1)

more(1)

mp(1)

mpss.so.1(1)

msgcc(1)

msgcpp(1)

msgcvt(1)

msgfmt(1)

msggen(1)

msgget(1)

mt(1)

mv(1)

nawk(1)

nc(1)

ncab2clf(1)

ncakmod(1)

neqn(1)

netcat(1)

newform(1)

newgrp(1)

newsp(1)

newtask(1)

nice(1)

nl(1)

nm(1)

nohup(1)

notify(1)

nroff(1)

od(1)

on(1)

onintr(1)

optisa(1)

pack(1)

packagemanager(1)

page(1)

pagesize(1)

pargs(1)

passwd(1)

paste(1)

patch(1)

pathchk(1)

pax(1)

pcat(1)

pcred(1)

perl(1)

pfbash(1)

pfcsh(1)

pfexec(1)

pfiles(1)

pfksh(1)

pflags(1)

pfsh(1)

pftcsh(1)

pfzsh(1)

pg(1)

pgrep(1)

pkcs11_inspect(1)

pkg(1)

pkgdepend(1)

pkgdiff(1)

pkgfmt(1)

pkginfo(1)

pkglint(1)

pkgmerge(1)

pkgmk(1)

pkgmogrify(1)

pkgparam(1)

pkgproto(1)

pkgrecv(1)

pkgrepo(1)

pkgsend(1)

pkgsign(1)

pkgtrans(1)

pkill(1)

pklogin_finder(1)

pktool(1)

plabel(1)

pldd(1)

plgrp(1)

plimit(1)

pmadvise(1)

pmap(1)

pm-updatemanager(1)

popd(1)

ppgsz(1)

ppriv(1)

pr(1)

praliases(1)

prctl(1)

preap(1)

print(1)

printenv(1B)

printf(1)

priocntl(1)

proc(1)

prof(1)

profiles(1)

projects(1)

prs(1)

prt(1)

prun(1)

ps(1)

ps(1B)

psig(1)

pstack(1)

pstop(1)

ptime(1)

ptree(1)

pushd(1)

pvs(1)

pwait(1)

pwd(1)

pwdx(1)

radadrgen(1)

ranlib(1)

rcapstat(1)

rcp(1)

read(1)

readonly(1)

red(1)

refer(1)

regcmp(1)

rehash(1)

remote_shell(1)

remsh(1)

renice(1)

repeat(1)

reset(1B)

return(1)

rksh(1)

rksh88(1)

rlogin(1)

rm(1)

rmail(1)

rmdel(1)

rmdir(1)

rmformat(1)

rmmount(1)

rmumount(1)

roffbib(1)

roles(1)

rpcgen(1)

rpm2cpio(1)

rsh(1)

runat(1)

rup(1)

rup(1C)

ruptime(1)

rusage(1B)

rusers(1)

rwho(1)

sact(1)

sar(1)

sccs(1)

sccs-admin(1)

sccs-cdc(1)

sccs-comb(1)

sccs-delta(1)

sccsdiff(1)

sccs-get(1)

sccs-help(1)

sccshelp(1)

sccs-prs(1)

sccs-prt(1)

sccs-rmdel(1)

sccs-sact(1)

sccs-sccsdiff(1)

sccs-unget(1)

sccs-val(1)

scp(1)

script(1)

sdiff(1)

sed(1)

sed(1B)

select(1)

set(1)

setenv(1)

setfacl(1)

setlabel(1)

setpgrp(1)

settime(1)

sftp(1)

sh(1)

shcomp(1)

shell_builtins(1)

shift(1)

shutdown(1B)

size(1)

sleep(1)

soelim(1)

sort(1)

sortbib(1)

sotruss(1)

source(1)

sparc(1)

spell(1)

spellin(1)

split(1)

srchtxt(1)

ssh(1)

ssh-add(1)

ssh-agent(1)

ssh-http-proxy-connect(1)

ssh-keygen(1)

ssh-keyscan(1)

ssh-socks5-proxy-connect(1)

stop(1)

strchg(1)

strconf(1)

strings(1)

strip(1)

stty(1)

stty(1B)

sum(1)

sum(1B)

sun(1)

suspend(1)

svcprop(1)

svcs(1)

switch(1)

symorder(1)

sys-suspend(1)

sysV-make(1)

t300(1)

t300s(1)

t4014(1)

t450(1)

tabs(1)

tail(1)

talk(1)

tar(1)

tbl(1)

tcopy(1)

tee(1)

tek(1)

telnet(1)

test(1)

test(1B)

tftp(1)

time(1)

timemanp(1)

times(1)

timesysp(1)

timex(1)

tip(1)

touch(1)

touch(1B)

tplot(1)

tput(1)

tr(1)

tr(1B)

trap(1)

troff(1)

true(1)

truss(1)

tset(1B)

tsort(1)

tty(1)

type(1)

typeset(1)

ul(1)

ulimit(1)

umask(1)

unalias(1)

uname(1)

uncompress(1)

unexpand(1)

unget(1)

unhash(1)

unifdef(1)

uniq(1)

units(1)

unix2dos(1)

unlimit(1)

unpack(1)

unset(1)

unsetenv(1)

until(1)

updatehome(1)

uptime(1)

userattr(1)

users(1B)

uucp(1C)

uudecode(1C)

uuencode(1C)

uuglist(1C)

uulog(1C)

uuname(1C)

uupick(1C)

uustat(1C)

uuto(1C)

uux(1C)

vacation(1)

val(1)

valdate(1)

valgid(1)

valint(1)

valpath(1)

valrange(1)

valstr(1)

valtime(1)

valuid(1)

valyorn(1)

vc(1)

vedit(1)

ver(1)

vgrind(1)

vi(1)

view(1)

vipw(1B)

volcheck(1)

volrmmount(1)

w(1)

wait(1)

wc(1)

what(1)

whatis(1)

whence(1)

whereis(1B)

which(1)

while(1)

who(1)

whoami(1B)

whocalls(1)

whois(1)

write(1)

xargs(1)

xgettext(1)

xstr(1)

yacc(1)

yes(1)

ypcat(1)

ypmatch(1)

yppasswd(1)

ypwhich(1)

zcat(1)

zlogin(1)

zonename(1)

zonestat(1)

请告诉我们如何提高我们的文档:
过于简略
不易阅读或难以理解
重要信息缺失
错误的内容
需要翻译的版本
其他
Your rating has been updated
感谢您的反馈!

您的反馈将非常有助于我们提供更好的文档。 您是否愿意参与我们的内容改进并提供进一步的意见?

find

- find files

用法概要

/usr/bin/find [-H | -L] path... expression
/usr/xpg4/bin/find [-H | -L] path... expression

描述

The find utility recursively descends the directory hierarchy for each path seeking files that match a Boolean expression written in the primaries specified below.

find is able to descend to arbitrary depths in a file hierarchy and does not fail due to path length limitations (unless a path operand specified by the application exceeds PATH_MAX requirements).

find detects infinite loops; that is, entering a previously visited directory that is an ancestor of the last file encountered.

选项

The following options are supported:

-H

Causes the file information and file type evaluated for each symbolic link encountered on the command line to be those of the file referenced by the link, and not the link itself. If the referenced file does not exist, the file information and type is for the link itself. File information for all symbolic links not on the command line is that of the link itself.

-L

Causes the file information and file type evaluated for each symbolic link to be those of the file referenced by the link, and not the link itself. See NOTES.

Specifying more than one of the mutually-exclusive options -H and -L is not considered an error. The last option specified determines the behavior of the utility.

操作数

The following operands are supported:

path

A pathname of a starting point in the directory hierarchy.

expression

The first argument that starts with a -, or is a ! or a (, and all subsequent arguments are interpreted as an expression made up of the following primaries and operators. In the descriptions, wherever n is used as a primary argument, it is interpreted as a decimal integer optionally preceded by a plus (+) or minus (-) sign, as follows:

+n

more than n

n

exactly n

-n

less than n

Expressions

Valid expressions are:

-acl

True if the file have additional ACLs defined.

-amin n

File was last accessed n minutes ago.

-atime n

True if the file was accessed n days ago. The access time of directories in path is changed by find itself.

-cmin n

File's status was last changed n minutes ago.

-cpio device

Always true. Writes the current file on device in cpio format (5120-byte records).

-ctime n

True if the file's status was changed n days ago.

-depth

Always true. Causes descent of the directory hierarchy to be done so that all entries in a directory are acted on before the directory itself. This can be useful when find is used with cpio(1) to transfer files that are contained in directories without write permission.

-exec command

True if the executed command returns a zero value as exit status. The end of command must be punctuated by an escaped semicolon (;). A command argument {} is replaced by the current pathname. If the last argument to -exec is {} and you specify + rather than the semicolon (;), the command is invoked fewer times, with {} replaced by groups of pathnames. If any invocation of the command returns a non-zero value as exit status, find returns a non-zero exit status.

-follow

Always true and always evaluated no matter where it appears in expression. The behavior is unspecified if -follow is used when the find command is invoked with either the -H or the -L option. Causes symbolic links to be followed. When following symbolic links, find keeps track of the directories visited so that it can detect infinite loops. For example, such a loop would occur if a symbolic link pointed to an ancestor. This expression should not be used with the find-type l expression. See NOTES.

-fstype type

True if the filesystem to which the file belongs is of type type.

-group gname

True if the file belongs to the group gname. If gname is numeric and does not appear in the group(4) database, it is taken as a group ID.

-iname pattern

Similar to -name, but the match between the pattern and the base name of the current file name is case insensitive. (See EXAMPLES). Unlike the -name option, there is no special treatment in leading period and wildcard file name generation characters can match file names beginning with a . for both /usr/bin/find and /usr/xpg4/bin/find.

-inum n

True if the file has inode number n.

-links n

True if the file has n links.

-local

True if the file system type is not a remote file system type as defined in the /etc/dfs/fstypes file. nfs is used as the default remote filesystem type if the /etc/dfs/fstypes file is not present. The -local option descends the hierarchy of non-local directories. See EXAMPLES for an example of how to search for local files without descending.

-ls

Always true. Prints current pathname together with its associated statistics. These include (respectively):

  • inode number

  • size in kilobytes (1024 bytes)

  • protection mode

  • number of hard links

  • user

  • group

  • size in bytes

  • modification time.

If the file is a special file, the size field instead contains the major and minor device numbers.

If the file is a symbolic link, the pathname of the linked-to file is printed preceded by `'. The format is identical to that of ls -gilds (see ls(1B)).

Formatting is done internally, without executing the ls program.

-mmin n

File's data was last modified n minutes ago.

-mount

Always true. Restricts the search to the file system containing the directory specified. Does not list mount points to other file systems.

-mtime n

True if the file's data was modified n days ago.

-name pattern

True if pattern matches the basename of the current file name. Normal shell file name generation characters (see sh(1)) can be used. A backslash ( \ ) is used as an escape character within the pattern. The pattern should be escaped or quoted when find is invoked from the shell.

Unless the character '.' is explicitly specified in the beginning of pattern, a current file name beginning with '.' does not match pattern when using /usr/bin/find. /usr/xpg4/bin/find does not make this distinction; wildcard file name generation characters can match file names beginning with '.'.

-ncpio device

Always true. Writes the current file on device in cpio -c format (5120 byte records).

-newer file

True if the current file has been modified more recently than the argument file.

-nogroup

True if the file belongs to a group not in the group(4) database.

-nouser

True if the file belongs to a user not in the passwd(4) database.

-ok command

Like -exec, except that the generated command line is printed with a question mark first, and is executed only if the response is affirmative.

-perm [-]mode

The mode argument is used to represent file mode bits. It is identical in format to the symbolic mode operand, symbolic_mode_list, described in chmod(1), and is interpreted as follows. To start, a template is assumed with all file mode bits cleared. An op symbol of:

+

Set the appropriate mode bits in the template

-

Clear the appropriate bits

=

Set the appropriate mode bits, without regard to the contents of the file mode creation mask of the process

The op symbol of - cannot be the first character of mode, to avoid ambiguity with the optional leading hyphen. Since the initial mode is all bits off, there are no symbolic modes that need to use - as the first character.

If the hyphen is omitted, the primary evaluates as true when the file permission bits exactly match the value of the resulting template.

Otherwise, if mode is prefixed by a hyphen, the primary evaluates as true if at least all the bits in the resulting template are set in the file permission bits.

-perm [-]onum

True if the file permission flags exactly match the octal number onum (see chmod(1)). If onum is prefixed by a minus sign (-), only the bits that are set in onum are compared with the file permission flags, and the expression evaluates true if they match.

-print

Always true. Causes the current pathname to be printed.

-print0

Always true. Causes the current pathname to be printed followed by a null character, rather than the NEWLINE character that -printuses.

This allows file names that contain NEWLINEs or other types of white space to be correctly interpreted by programs that process the find output. This option corresponds to the -0 option of cpio and xargs.

-prune

Always yields true. Does not examine any directories or files in the directory structure below the pattern just matched. (See EXAMPLES). If -depth is specified, -prune has no effect.

-size n[c]

True if the file is n blocks long (512 bytes per block). If n is followed by a c, the size is in bytes.

-type c

True if the type of the file is c, where c is b, c, d, D, f, l, p, or s for block special file, character special file, directory, door, plain file, symbolic link, fifo (named pipe), or socket, respectively.

-user uname

True if the file belongs to the user uname. If uname is numeric and does not appear as a login name in the passwd(4) database, it is taken as a user ID.

-xdev

Same as the -mount primary.

-xattr

True if the file has extended attributes.

Complex Expressions

The primaries can be combined using the following operators (in order of decreasing precedence):

1)(expression)

True if the parenthesized expression is true (parentheses are special to the shell and must be escaped).

2)!expression

The negation of a primary (! is the unary not operator).

3) expression[-a] expression

Concatenation of primaries (the and operation is implied by the juxtaposition of two primaries).

4) expression-oexpression

Alternation of primaries (-o is the or operator).

When you use find in conjunction with cpio, if you use the -L option with cpio, you must use the -L option or the -follow primitive with find and vice versa. Otherwise the results are unspecified.

If no expression is present, -print is used as the expression. Otherwise, if the specified expression does not contain any of the primaries -exec, -ok, -ls, or -print, the specified expression is effectively replaced by:

(specified) -print

The -user, -group, and -newer primaries each evaluate their respective arguments only once. Invocation of command specified by -exec or -ok does not affect subsequent primaries on the same file.

用法

See largefile(5) for the description of the behavior of find when encountering files greater than or equal to 2 Gbyte (231 bytes).

示例

示例 1 Writing Out the Hierarchy Directory

The following commands are equivalent:

example% find .
example% find . -print

They both write out the entire directory hierarchy from the current directory.

示例 2 Removing Files

The following comand removes all files in your home directory named a.out or *.o that have not been accessed for a week:

example% find $HOME \( -name a.out -o -name '*.o' \) \
       -atime +7 -exec rm {} \; 

示例 3 Printing All File Names But Skipping SCCS Directories

The following command recursively print all file names in the current directory and below, but skipping SCCS directories:

example% find . -name SCCS -prune -o -print

示例 4 Printing all file names and the SCCS directory name

Recursively print all file names in the current directory and below, skipping the contents of SCCS directories, but printing out the SCCS directory name:

example% find . -print -name SCCS -prune

示例 5 Testing for the Newer File

The following command is basically equivalent to the -nt extension to test(1):

example$ if [ -n "$(find
file1 -prune -newer file2)" ]; then

printf %s\\n "file1 is newer than file2"

示例 6 Selecting a File Using 24–hour Mode

The descriptions of -atime, -ctime, and -mtime use the terminology n ``24-hour periods''. For example, a file accessed at 23:59 is selected by:

example% find . -atime -1 -print

at 00:01 the next day (less than 24 hours later, not more than one day ago). The midnight boundary between days has no effect on the 24-hour calculation.

示例 7 Printing Files Matching a User's Permission Mode

The following command recursively print all file names whose permission mode exactly matches read, write, and execute access for user, and read and execute access for group and other:

example% find . -perm u=rwx,g=rx,o=rx

The above could alternatively be specified as follows:

example% find . -perm a=rwx,g-w,o-w

示例 8 Printing Files with Write Access for other

The following command recursively print all file names whose permission includes, but is not limited to, write access for other:

example% find . -perm -o+w

示例 9 Printing Local Files without Descending Non-local Directories

example% find . ! -local -prune -o -print

示例 10 Printing the Files in the Name Space Possessing Extended Attributes

example% find . -xattr

示例 11 Printing all PDF Filenames Regardless of Case

The following example finds all file names with an extension of .pdf, .PDF, .Pdf, and so forth.

example% find . -iname '*.pdf'

环境变量

See environ(5) for descriptions of the following environment variables that affect the execution of find: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH.

PATH

Determine the location of the utility_name for the -exec and -ok primaries.

Affirmative responses are processed using the extended regular expression defined for the yesexpr keyword in the LC_MESSAGES category of the user's locale. The locale specified in the LC_COLLATE category defines the behavior of ranges, equivalence classes, and multi-character collating elements used in the expression defined for yesexpr. The locale specified in LC_CTYPE determines the locale for interpretation of sequences of bytes of text data a characters, the behavior of character classes used in the expression defined for the yesexpr. See locale(5).

退出状态

The following exit values are returned:

0

All path operands were traversed successfully.

>0

An error occurred.

文件

/etc/passwd

Password file

/etc/group

Group file

/etc/dfs/fstypes

File that registers distributed file system packages

属性

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Availability
system/core-os
CSI
Enabled
Interface Stability
Committed
Standard

另请参见

chmod(1), cpio(1), sh(1), test(1), ls(1B), acl(2), stat(2), umask(2), group(4), passwd(4), attributes(5), environ(5), fsattr(5), largefile(5), locale(5), standards(5)

警告

The following options are obsolete and will not be supported in future releases:

-cpio device

Always true. Writes the current file on device in cpio format (5120-byte records).

-ncpio device

Always true. Writes the current file on device in cpio -c format (5120–byte records).

附注

When using find to determine files modified within a range of time, use the -mtime argument before the -print argument. Otherwise, find gives all files.

Some files that might be under the Solaris root file system are actually mount points for virtual file systems, such as mntfs or namefs. When comparing against a ufs file system, such files are not selected if -mount or -xdev is specified in the find expression.

Using the -L or -follow option is not recommended when descending a file-system hierarchy that is under the control of other users. In particular, when using -exec, symbolic links can lead the find command out of the hierarchy in which it started. Using -type is not sufficient to restrict the type of files on which the -exec command operates, because there is an inherent race condition between the type-check performed by the find command and the time the executed command operates on the file argument.