![]() find ~/ -name "tutorials" -type d Executing Commands Against Found Files Files will be ignored and they will not be included in your search results. find /var/log -newerct `10 minutes ago` -print Finding a DirectoryĪlternative, to narrow your search down to directories only, you can use use the -type flag with the value d. To find a file a file created within the last 10 minutes you use the -newerct command. Have you ever needed to find a file that was created within the last few minutes or day? Thankfully, the find command also supports finding files and directories based on age. find /opt/service -uid 1024 Finding Files based on Age find /opt/service -user jsmithĪlternatively, to search by user ID instead you the -uid flag. To find files owned by a user named jsmith, you use the -flag in your comand with the name of the user. We have the option of searching by username or even uid (user id). find /my/media -type f -size 2G Finding Files Owned by a Userįinding files based on ownsership is also possible. The following example searches for files that are 2 gigabytes in size, rounded up by blocks of 512 bytes. The size can be represented in kilobytes, megabytes, gigabytes, terabytes, or even petabytes. To narrow your results, the find command can search for files matching a specific size. The -type f instructs the find command to only match the -name string against files. ![]() ![]() Using the example above, in order to find just files with the name “tutorials” you would execute the following command. To narrow your search down to files only you use the -type flag with the find command. The basic syntax of the find command looks like the following find -name=įor example, to search for a file or directory named “tutorials” from your home directory, you would execute the following command. By default it will match a string against both files and directories. The find command can used to find files, directories or both. You will also learn how to execute commands against files returned by the find command. In this tutorial, you will learn how to use the find command to find files and directories on your Linux filesystems. ![]()
0 Comments
Leave a Reply. |