Editing
Solaris 10 Associate
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== find command ==== use <code>find</code> command to locate files or directories in the directory hierarchy <code>find</code> command recursively descends the directory tree in the path name list, looking for files that match search criteria as <code>find</code> command matches files matching search criteria the absolute path for each file is displayed on screen syntax: <code>find pathname expression action</code> <code>find</code> command arguments: * pathname = absolute or relative path where the search originates * expression = search criteria specified by one or more options. specifying multiple options causes the find command to use the boolean operator <code>and</code>, so all listed expressions must be verified as true * action = action required after the files have been located. the default print action is to print all path names matching the criteria to the screen ===== find expressions ===== some expressions for <code>find</code> command <table style="text-align: left; width: 50%;" border="1" cellpadding="0" cellspacing="0"> <tr> <td>expression</td> <td>definition</td> </tr> <tr> <td>-name filename</td> <td>finds files matching the specified filename, metacharacters are acceptable if placed inside quote marks " " or ' '</td> </tr> <tr> <td>-inum [integer]</td> <td>finds files by inode #</td> </tr> <tr> <td>-size [+|-]n</td> <td>finds files that are > +n or < -n or = n. n is 512-byte blocks</td> </tr> <tr> <td>-atime [+|-]n</td> <td>finds files that have been accessed > +n or < -n or = n. n is days</td> </tr> <tr> <td>-mtime [+|-]n</td> <td>find files that have been modified > +n or < -n or = n. n is days</td> </tr> <tr> <td>-user userID</td> <td>finds all files that are owned by the userID</td> </tr> <tr> <td>-type</td> <td>finds a file type, for example f = file and d = directory</td> </tr> <tr> <td>-perm</td> <td>finds files that have certain access permission bits</td> </tr> </table> ===== find actions ===== <table style="text-align: left; width: 50%;" border="1" cellpadding="0" cellspacing="0"> <tr> <td>action</td> <td>definition</td> </tr> <tr> <td>-exec command {} \;</td> <td>runs the specified command on each file located. a set of braces { } delimits where the file name is passed to the command from the preceding expressions. a space, backslash, and semicolon (\;) delimits the end of the command. There must be a space before the backslash (\)</td> </tr> <tr> <td>-ok command {} \;</td> <td>requires confirmation before find command applies the command to each file located. this is the interactive form of the -exec command</td> </tr> <tr> <td>-print</td> <td>instructs the find command to print the current path name to terminal session. this is the default</td> </tr> <tr> <td>-ls</td> <td>displays the current path name and associated statistics, such as the inode number, the size in kilobytes, protection mode, the number of hard links, and the user</td> </tr> </table> ===== find examples ===== <insert examples> search home directory looking for files or directories called deleteme and asking before deleting any matches perform this command: <code>$ find ~ -name deleteme -ok rm {} \;</code> to look for all files that have not been modified in the last two days starting in current directory perform this command: <code>$ find . -mtime +2</code> remove files without confirmation that have been modified greater than 30 days in current working directory <code>find . -mtime +30 -exec rm -f {} \;</code> to find files larger than 10 blocks (512-byte blocks X 10 = 5,120 bytes) starting in your home directory perform this command: <code>$ find ~ -size +10</code>
Summary:
Please note that all contributions to GotOpinion may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
GotOpinion:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information