There are many different applications that can do a good job for you. In short, Find Command in Unix returns all files below the current working directory. Further, find command allows the user to specify an action to be taken on each matched file.For Linux users, the need to search for words in one or multiple files arises quite often. Search for files that have all permissions set in the current hierarchy $ find. Search for files that were modified in the last 7 days below the current directory $ find. Search for a file by the name abc.txt below the current directory, and prompt the user to delete each match. Search for a directory by the name xyz in the current directory and its hierarchy $ find. Search for a file by the name abc in the current directory and its hierarchy $ find. List all files found in the current hierarchy, and all the hierarchy below /home/xyz $ find. List all files found in the current directory and its hierarchy $ find. The expr2 is only evaluated of expr1 is false. expr1 -o expr2: The result is an ‘or’ of the two expressions.expr1 expr2: The ‘and’ operator is implicit in this case.The expr2 is only evaluated of expr1 is true. expr1 -a expr2: The result is an ‘and’ of the two expressions.The expression is evaluated from left to right and is put together using the following operators.-prune: If the file is a directory, do not descend into it, and return true.-print: Print the name of the matching file.-ls: List the matching file as the per ‘ls -dils’ format.-ok command: Like the ‘exec’ expression, but confirms with the user first.-exec command: Execute the given command for each matching file, and return true if the return value is 0.-delete: Delete the matched file, and return true if successful. If not actions are specified, the ‘-print’ action is performed for all matching files. The action expressions are used to define actions that have side effects and may return true or false.-username: Returns true if the file is owned by username ‘name’.‘b’ for block device file, ‘d’ for directory etc.). -type c: Returns true if the file is of type c (e.g.-perm – mode: Returns true if all the permission bits for mode are set for the file.-size n: Returns true if the file size is n blocks.-regex pattern: Returns true if the file’s name with the path matches the regular expression.-path pattern: Returns true if the file’s name with the path matches the shell pattern.-iname pattern: Returns true if the file’s name matches the provided shell pattern.-name pattern: Returns true if the file’s name matches the provided shell pattern.-mtime n: Returns true if the file’s contents were modified n days ago.-ctime n: Returns true if the file’s status was changed n days ago.-atime n: Returns true if the file was accessed n days ago.(Wherever a count ‘n’ is used: without any prefix the match is for the exact value of n with a ‘+’ prefix, the match is for values greater than n and with a ‘-‘ prefix, the match is for values lesser than n.) Test expressions are used to evaluate specific properties of the files and return true or false accordingly.-mindepth: the min levels beyond the provided paths to descend before matching.-maxdepth: the max levels below the provided paths to descend for a match.-depth: process the directory contents before processing the directory itself.Option expressions are used to constrain the find operation, and always return true.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |