The Open Source Swiss Army Knife
/unix/commandline/
/unix/commandline/
+
sub-categories
http://www.sirfsup.com/
web directory content
Not logged in
Chat
Register
Login
unix
sql_servers
cryptography
code
web_servers
xml
programmingToolBox
miscellany
windows
web_design
return to:
http:/www.sirfsup.com
/
unix
/
commandline
Permalink:
find.htm
Title:
add
article options : please login
|
print view
getting around with commands on linux: find
finding files
finding files
find PLACE_TO_LOOK -name PATTERN -fstype DO_NOT_SEARCH_HERE
-xdev -mount. -ftstype TYPE
-> leaves out other filesystems, meaning other partitions, say if /usr/local is on one and you're searching /usr
-fstype is usually used with
-prune
to avoid searching remote filesystems. -> searchs the directories and sub-directories
find /usr/src -name '*.c' -size +100K -print
-> prints the names of all files in /usr/src whose names end in
.c
and that are larger than 100 Kb.
find /usr/include -name "*.h" -exec grep 'tcp' {} \; -print
find . -xdev -type f \( -mtime 0 -or -mtime 1 \) -exec cp -aPv "{}" $dest.new \;
find / -nouser -o -nogroup -print
:locate files that have no user or no group
find / -perm -2 ! -type l -ls
: locates all world-writable files on the system
find / -type f \( -perm -04000 -o -perm -02000 \)
: finds all suid and guid files
find . -type f -exec grep -l 192.168.100.3 {} \; -> (finds dhcp server on a linux box from a windows machine)
-atime 7 -- > finds all files which have not been modified in atleast 7 days
-type d -- > finds directories
-type f -- > finds files
-type size e.g. 100k
-type l -> is a symbolic link
-follow
-> dereference the symbolic link
find /usr/include -type -f -follow -name "*.h" | xargs grep -E1 `#define *PAGE_OFFSET_RAW`
-> searches in the results from
find
for lines containing PAGE_OFFSET_RAW
find . -type f -print | xargs grep -l WARNING
locate
searches special file name databases for file names that match patterns
from php-4.3.0; make clean issues the following:
[root@www php-4.3.0]# make clean
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp4.la sapi/cli/php libphp4.la modules/* libs/*
http://pauillac.inria.fr/~leifer/recipes.html
find . -not -type l -and \( -perm +020 -or -perm +002 \) -exec chmod og-w {} \;
find . -type f -maxdepth 1 -regex '\./[0-9]+' -printf "%P\n"
(-type f: only files
-maxdepth 1: only files in the current directory
-regex '\./[0-9]+' digits
-printf "%P\n" omit leading ./
)
dist-hook: find $(distdir) -type d -name CVS -print | xargs $(RM) -f
Leave a Reply
Your Name:
anonymous
Your Email:
Website:
Comments:
The author will be notified of your reply.
return to top