'Linux'에 해당하는 글 1건

Linux find 명령

Linux 2012. 2. 2. 14:29
Usage: find [PATH]... [EXPRESSION]

Search for files. The default PATH is the current directory,
default EXPRESSION is '-print'

EXPRESSION may consist of:
	-follow		Follow symlinks
	-xdev		Don't descend directories on other filesystems
	-maxdepth N	Descend at most N levels. -maxdepth 0 applies
			tests/actions to command line arguments only
	-mindepth N	Don't act on first N levels
	-name PATTERN	File name (w/o directory name) matches PATTERN
	-iname PATTERN	Case insensitive -name
	-path PATTERN	Path matches PATTERN
	-regex PATTERN	Path matches regex PATTERN
	-type X		File type is X (X is one of: f,d,l,b,c,...)
	-perm NNN	Permissions match any of (+NNN), all of (-NNN),
			or exactly NNN
	-mtime DAYS	Modified time is greater than (+N), less than (-N),
			or exactly N days
	-mmin MINS	Modified time is greater than (+N), less than (-N),
			or exactly N minutes
	-newer FILE	Modified time is more recent than FILE's
	-inum N		File has inode number N
	-user NAME	File is owned by user NAME (numeric user ID allowed)
	-group NAME	File belongs to group NAME (numeric group ID allowed)
	-depth		Process directory name after traversing it
	-size N[bck]	File size is N (c:bytes,k:kbytes,b:512 bytes(def.))
			+/-N: file size is bigger/smaller than N
	-links N	Number of links is greater than (+N), less than (-N),
			or exactly N
	-print		Print (default and assumed)
	-print0		Delimit output with null characters rather than
			newlines
	-exec CMD ARG ;	Run CMD with all instances of {} replaced by the
			matching files
	-prune		Stop traversing current subtree
	-delete		Delete files, turns on -depth option
	(EXPR)		Group an expression

※ 예제

# 파일의 개수만 표시 
find -type f |wc -l

# 내용으로 파일 검색 

XML 안에서 rainDrop 단어를 검색

find ./ -name '*.xml'  -type f |xargs grep 'rainDrop'




 







WRITTEN BY
Peter Ryu
Crazy Programmer's World

,