sudo : for executing command by using admin privilage .
find command
Visit POWER TOOLS:A Very Valuable Find, by Jerry Peek, for creative ways to use find and important tips about constructing the command's options.
find command
Find a file "foo.bar" that exists somewhere in the filesystem
$ find / -name foo.bar -print |
Find a file without searching network or mounted filesystems
$ find / -name foo.bar -print -xdev |
Find a file without showing "Permission Denied" messages
$ find / -name foo.bar -print 2>/dev/null |
Find a file, who's name ends with .bar, within the current directory and only search 2 directories deep
$ find . -name *.bar -maxdepth 2 -print |
Search directories "./dir1" and "./dir2" for a file "foo.bar"
$ find ./dir1 ./dir2 -name foo.bar -print |
Search for files that are owned by the user "joebob"
$ find /some/directory -user joebob -print |
Find a file that is a certain type. "-type l" searches for symbolic links
$ find /some/directory -type l -print |
- b block (buffered) special
c character (unbuffered) special
d directory
p named pipe (FIFO)
f regular file
l symbolic link
s socket
D door (Solaris)
Search for directories that contain the phrase "foo" but do not end in ".bar"
$ find . -name '*foo*' ! -name '*.bar' -type d -print |
The power of find
find becomes extremely useful when combined with other commands. One such combination would be using find and grep together.
$ find ~/documents -type f -name '*.txt' \
-exec grep -s DOGS {} \; -print |
Visit POWER TOOLS:A Very Valuable Find, by Jerry Peek, for creative ways to use find and important tips about constructing the command's options.
No comments:
Post a Comment