For instance, to find all files whose name ends in. You can also use wildcards as part of your file name. To restrict your search results to match only files and directories with a certain name, use the -name option and put the name in quotes: find. archlinux-2016.02.01-dual.iso Finding by name Specifying -maxdepth 3 searches one level deeper than that: find. Specifying -maxdepth 2 searches the directory and one subdirectory deep: find. If any subdirectories are found, they are listed, but not searched. If you want to restrict how many levels of subdirectory to search, you can use the -maxdepth option with a number.įor instance, specifying -maxdepth 1 searches only in the directory where the search begins. imagesīy default, the search looks in every subdirectory of your starting location. imagesīut this time, the output reflects the starting location of the search and looks like this. If our working directory is /home/hope/Documents, we can use the following command, which finds the same files: find.
#Whm list directory contents permission full#
Notice that the full path is also shown in the results. home/hope/Documents/images/memes/picard.jpg home/hope/Documents/images/memes/goodguygary.JPG home/hope/Documents/images/memes/winteriscoming.jpg To only list files and subdirectories that are contained in the directory /home/hope/Documents/images, specify the first argument of the command as: find /home/hope/Documents/images /home/hope/Documents/images It's good practice to use this form of the command. If you try to use it on another Unix-like operating system, such as FreeBSD, specifying a directory is required. The example above is the "proper" way to use find. Running find with no options is the same as specifying that the search should begin in the working directory, like this: find. Notice that the output starts with a single dot, which represents the working directory. In this example, we see a total of ten files and four subdirectories in and beneath our Documents folder. Now let's run find without any options: find. First, let's check our working directory using the pwd command: pwd /home/hope/Documents
Running find without any options produces a list of every file and directory in and beneath the working directory. Finding files based on modification, access, or status change.Finding only files, or only directories.