montanaoreo.blogg.se

Linux find directory by name
Linux find directory by name







linux find directory by name

Specifying -maxdepth 2 searches the directory and one subdirectory deep: find. If any subdirectories are found, they are listed, but not searched. 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.

#LINUX FIND DIRECTORY BY NAME FULL#

Notice that the full path is also shown in the results. home/hope/Documents/images/memes/picard.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.

linux find directory by name

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 Every file in each of those subdirectories.Every subdirectory in /home/hope/Documents.For instance, if your working directory is /home/hope/Documents, running find outputs the following: 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.









Linux find directory by name