Using find command in Linux

Find is a very useful utility available in all the Linux server across all the variants, in this post let’s discuss some of the use cases of the command “find“.

You are in a directory with thousands of files and you want to specifically search for “.png” and “.php” files.

You can achieve this by running the following command on the bash and in the directpoy where you want to initiate a search.

find . -type f \( -name "*.png" -o -name "*.php" \)

Below would be the expected output

[root@localhost ]# find . -type f \( -name "*.png" -o -name "*.php" \)

Now, let say you want to search for two specific files in a directory. You know the names of the files that you want to search, in that you can use the below command syntax to find those files that you are looking for.

File names that I want to search is “functions.php” and “config.php

[root@localhost public_html]# find -name "config.php" -o -name "functions.php"

Below would be the expected output

[root@localhost public_html]# find -name "config.php" -o -name "functions.php"