The find
Linux command is designed to go looking and to find information and directories in your gadget. In contrast to different seek instructions like to find
, find
provides a faster seek via having access to a database of the information and directories.
Working out the find
command opens doorways to environment friendly record control in Linux. Very similar to the to find
command, however incessantly quicker, find
is used to temporarily pinpoint the positioning of information and directories. It’s specifically at hand for IT pros, builders, and Linux lovers who want to navigate complicated record methods. For the ones having a look to toughen their workflow, combining the find
command with instructions like updatedb
can additional streamline the quest procedure.
Methods to Set up the find
Command
The find
command will not be put in via default on some Linux distributions. Right here’s how you’ll be able to set up and uninstall it, looked after via distribution:
Debian-based Methods (e.g., Ubuntu)
Set up:
sudo apt-get replace sudo apt-get set up mlocate
Uninstall:
sudo apt-get take away mlocate
Pink Hat-based Methods (e.g., Fedora, CentOS)
Set up:
sudo dnf set up mlocate
Uninstall:
sudo dnf take away mlocate
Arch Linux
Set up:
sudo pacman -S mlocate
Uninstall:
sudo pacman -R mlocate
openSUSE
Set up:
sudo zypper set up mlocate
Uninstall:
sudo zypper take away mlocate
Methods to Use find
1. Restricting the Selection of Effects
Syntax: find -n
Rationalization: Limits the collection of seek effects.
Instance: find -n 1 myfile.txt
Output:
/house/person/paperwork/myfile.txt
The command has situated just one example of myfile.txt
because of the restrict set via the -n
possibility.
2. Ignoring Case Sensitivity
Syntax: find -i
Rationalization: Searches for information or directories with out bearing in mind case sensitivity.
Instance: find -i MyFile.txt
Output:
/house/person/paperwork/myfile.txt /var/www/html/MyFile.txt
The command has situated two cases of MyFile.txt
ignoring the case.
3. Looking Inside a Particular Listing
Syntax: find --regex
Rationalization: Searches for information or directories the use of common expressions.
Instance: find --regex '/house/person/paperwork/.*.txt'
Output:
/house/person/paperwork/myfile.txt /house/person/paperwork/anotherfile.txt
The command has situated all textual content information throughout the /house/person/paperwork
listing the use of an ordinary expression.
4. Counting the Selection of Matching Information
Syntax: find -c
Rationalization: Counts the collection of matching information or directories.
Instance: find -c myfile.txt
Output:
2
The command has counted two cases of myfile.txt
in several directories.
5. Showing Handiest Information Changed Inside a Positive Selection of Days
Syntax: find --time
Rationalization: Presentations information changed inside a specified collection of days.
Instance: find --time 7 myfile.txt
Output:
/house/person/paperwork/myfile.txt
The command has situated one example of myfile.txt
that was once changed throughout the ultimate 7 days.
6. Showing Statistics Concerning the Find Database
Syntax: find -S
Rationalization: Presentations statistics in regards to the find database.
Instance: find -S
Output:
Database /var/lib/mlocate/mlocate.db: 18,234 directories 72,564 information 2,345,678 bytes in record names 456,789 bytes used to retailer database
The command has displayed statistics in regards to the find database, together with the collection of directories, information, and bytes used.
7. The use of a Customized Database with Find
Syntax: find -d
Rationalization: Makes use of a specified database as a substitute of the default one.
Instance: find -d /trail/to/customized/database.db myfile.txt
Output:
/customized/trail/paperwork/myfile.txt
The command has situated myfile.txt
the use of a customized database laid out in the -d possibility.
9. Aside from Particular Paths from the Seek
Syntax: find --exclude
Rationalization: Excludes particular paths from the quest effects.
Instance: find --exclude /var myfile.txt
Output:
/house/person/paperwork/myfile.txt
The command has situated myfile.txt
however excluded effects from the /var
listing.
10. Finding a Particular Document or Listing
Syntax: find
Rationalization: Reveals the positioning of a selected record or listing.
Instance: find myfile.txt
Output:
/house/person/paperwork/myfile.txt /var/www/html/myfile.txt
The command has situated two cases of myfile.txt
in several directories.
Extra Linux instructions:
Listing Operations | rmdir · cd · pwd |
Document Operations | cat · cp · dd · much less · ls · mkdir · mv · tail · tar · zip |
Document Device Operations | chown · mkfs |
Networking | ping · curl · wget · iptables |
Seek and Textual content Processing | to find · grep · sed · whatis |
Device Data and Control | env · historical past · most sensible · who |
Consumer and Consultation Control | display · su · sudo |
The publish Methods to Use the ‘find’ Command in Linux gave the impression first on Hongkiat.
WordPress Website Development Source: https://www.hongkiat.com/blog/linux-command-locate/