AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Find a file by name linux12/15/2023 ![]() ![]() ![]() Using the find command in a proper way can make your task easier. We will also learn about the locate command which is also a faster way to search for the files by name. We will look at the different arguments that can be used with the find command. In this tutorial, we will be focusing on finding the files by name. To make this task easier, Linux offers certain commands to do this job for you.įind is a popular command used in the Linux systems that can help you search for various files based on their names, type, extension, permissions, owner, etc. Finding it conventionally may be a time-consuming task. However, sometimes it becomes a very tedious job to find an individual file in the huge pile of files on your system. pdf from the /home/sourcedigit:įind /vhome/sourcedigit -name `*.pdf` -deleteīe extra cautious using the delete option with the command.Users usually try to find a file using the GUI. For example, to delete all files ending with. To delete all matching files, add the -delete option to the end of the match expression. For example, to search for all files and directories owned by the user sourcedigit:įind / -user sourcedigit Find and Delete Files Similarly, one can easily serach the files by owner, particular user or group, use the -user and -group options. See the following command where we are searching all files in the /home directory that were modified 30 or more days ago:įind /home/sourcedigit -mtime +30 -daystart Simlarly we can search based on the modification date using the -daystart option. pdf and has been modified in the last five days:įind /home/sourcedigit -name "*.pdf" -mtime 5 See the following example where we will search all files under the /home/sourcedigit directory that ends with. For example, we wiant to find a file which was modified few days ago, but you forgot the name of the file. The most useful aspect of find command it to search for files based on their last modification, access, or change time. tar.gz inside the /home/sourcedigit directory, you would type:įind /home/sourcedigit -type f -name '*.tar.gz' Find Files by Modification Date For example, to find all files ending with. To find files by extension we will use the extension with the command. For example,įind /home/sourcedigit -type f -iname file123.xls Find Files by Extension To execute the command in a case-insensitive search, change the -name option with -iname. Note that the command option name is case sensitive by default. For example, to search for a file named file123.xls in the /home/sourcedigit directory, you would use the following command:įind /home/sourcedigit -type f -name file123.xls To find a file by its name, use the -name option along with the find command. The (expression) -name “*.xls tells find to search files ending with.The /Documents (path…) specifies the directory that will be searched.The option -L (options) tells the find command to follow symbolic links.For example it will define the file extension. expression defines the options, search patterns, and actions for the files to be searched.path… defines the starting directory or directories where find will be searched.In other words the type of file to search. options defines the treatment of the symbolic links and optimization method. ![]() The general syntax for the find command is find /path/ -type f -name file-to-search ![]()
0 Comments
Read More
Leave a Reply. |