IAMEM Hosting

Using find command in Linux

Home > Blog > Debian > Using find command in Linux
20Aug, 2016
0

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

[[email protected] ]# find . -type f \( -name "*.png" -o -name "*.php" \)
./includes/mail.php
./includes/pipe.php
./includes/upgrade.php
./includes/controller.php
./includes/contact-form-template.php
./includes/js/jquery-ui/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png
./includes/js/jquery-ui/themes/smoothness/images/ui-icons_222222_256x240.png
./includes/js/jquery-ui/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
./includes/js/jquery-ui/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
./includes/js/jquery-ui/themes/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
./includes/js/jquery-ui/themes/smoothness/images/ui-icons_2e83ff_256x240.png
./includes/js/jquery-ui/themes/smoothness/images/ui-icons_888888_256x240.png

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

[[email protected] public_html]# find -name "config.php" -o -name "functions.php"

Below would be the expected output

[[email protected] public_html]# find -name "config.php" -o -name "functions.php"
./plugins/akismet/views/config.php
./plugins/contact-form-7/includes/functions.php
./plugins/all-404-redirect-to-homepage/functions.php
./plugins/wordpress-seo/vendor/yoast/api-libs/google/config.php
./themes/frontier/functions.php
./functions.php

 

Leave a Reply

twelve + 5 =

Copyright © 2019 | iamemhost.com . All rights reserved.