7 Uses of find Command in Linux

Find it and do what you want

Yang Zhou
TechToFreedom

--

Photo by 420BongHits on Wallhaven

It’s safe to say that the find command in Linux is one of the must-know operations for backend developers, unless you are using a Windows Server.

For technical interviews, it’s also a popular topic. Let’s see a real question:

If there is a directory called logs on your Linux server, how to delete the log files under it whose last access time was over one year ago? 🤔

This scenario is common, but surprisingly, not every developer can write the command clearly in an interview.

Answer: First of all, we need to use the cd command to enter the corresponding directory, and then, the command is as follows:

find . -type f -atime +365 -exec rm -rf {} \; 

If you don’t fully understand the above command yet, no worries at all. This article will introduce 7 practical uses of the find command and you’ll master it eventually. If you already knew it, reading this article will be a great recap for you.

0. Find Files by Names or Regular Expressions

Let’s start from the simplest usage. To search files by a specific name, the command is like the following:

find . -name test.txt

--

--