You'll be able to find the file you edited in seconds after running the command. This limits your search from 1000+ files to a more manageable amount. In such cases, you can find all the files that were modified within the past 7 days. You're sure that you have edited only a couple of files after that. You edited a file in the past couple of days and forgot its name. Let's assume you have thousands of files in your directory. How to Search a File Based on Time ModifiedĮvery file has a created and last updated time associated with it. You can specify the size in your preferred notation. You can also search for all files that fall within a specific size range.įor example, if you want to find all the files that are above 50 MB and below 100 MB, you can run the following command: find /path/to/search -size +50M -size -100M find command syntax to search files within a range of size Terminal command to search files within a range In the above screenshot, we're finding all the files that have a size greater than 1 GB. find /path/to/search -size find command syntax to search files by size Terminal command to search files by size Prepend a + or - to the size to represent greater than and less than, respectively. Similarly the -type option accepts other parameter options to simplify our finding process.Īdding the -size option along with the find command helps you find files based on size. In the above screenshot, we're finding a directory named zip from our current directory. find /path/to/search -type d find command syntax to find a directory Terminal command to search a directory using find command Searching for a directory is possible by passing the d to the -type parameter in the find command. txt files in a particular directory and sub-directory, you can replace the /path/to/search with the path of your directory. txt files in your current directory and its sub-directories. find /path/to/search -name "*.txt" find command to search files matching a pattern Terminal command displaying file search by matching a pattern You can do so with the find command using the regex pattern ( *.txt). Let's assume you need to find all the files ending with the. You can also use the find command as an alternative to the ls command in some places. find -iname find command syntax to do a case-insensitive search Terminal command to do case-sensitive search If you are looking to do a case-insensitive search, you can use the -iname flag instead. find -name find command syntax to search a file by name Terminal command to search a file by nameīut remember the -name flag performs a case-sensitive search. Instead of searching the file manually on your computer, you can use the find command to automate the process.īy passing the name of the file using the -name flag, the find command searches and returns the location of the file. This is when the find command does a great job. Usually, if you forgot where you stored a file, you'd begin by going through folder after folder and checking if the file exists. But your boss is asking you to send them the file immediately. Let’s say you saved a file called hello_world.html somewhere and you don’t even remember the directory name. Let’s explore the power of the find command How to Search a File by Name It adds the flexibility to search for files in a specific directory or recursively through all sub-directories. The find command allows you to search for files and directories on your computer. This article will help you understand the basics of the most commonly used find command in Linux. Whether you’re a beginner or an expert, and if you're looking to take your file management skills to the next level, you've arrived at the right spot. Linux has an incredibly powerful command line that allows you to search files and directories in a fraction of a second. Many people are unaware of the power of Linux terminals. Have you ever felt frustrated searching for files manually on your computer? If you’re a developer or DevOps engineer working on GUI-less Linux servers, it'll be hard navigating back and forth to find files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |