The to find
command is used to look and find information and directories in line with specified stipulations reminiscent of document call, dimension, amendment date, and different attributes. You’ll use it to look thru your whole document machine or inside of a particular listing.
It’s usually utilized by machine directors and common customers to temporarily find information, particularly in programs with a lot of information. Whether or not you’re on the lookout for a misplaced report or want to carry out bulk operations on a suite of information that meet positive standards, the to find
command will also be an very important software in managing and organizing your document machine.
Normal syntax for to find
command:
$ to find [OPTIONS] [PATH...] [EXPRESSION]
1. Seek for particular document in a listing
to find ./ExampleDir -name instance.txt
With the -name
parameter, this command will try to seek for a instance.txt
throughout the ExampleDir
listing; and if discovered, will go back trail to the document.
./ExampleDir/subdir1/instance.txt ./ExampleDir/subdir2/subsubdir/instance.txt
2. In finding and listing information of identical extension
to find ./dirname -name *.txt
This command will seek, throughout the ExampleDir
listing, all information finishing with the extension .txt
. If discovered, every outcome will likely be returned in a brand new line.
./dirname/file1.txt ./dirname/file2.txt ./dirname/subdir/file3.txt ./dirname/subdir/another_subdir/file4.txt
3. In finding and listing empty information and empty sub-directories
to find ./ExampleDir -empty
This command, with the -empty
parameter, will to find and listing all empty information and empty sub-folders within the ExampleDir
folder.
Definition of empty document being 0 bytes filesize, and empty folder being no information or information with 0 bytes.
4. In finding and listing information that include particular textual content
to find ./ExampleDir -type f -name "*.txt" -exec grep 'Instance' {} ;
This command searches for the phrase/string “Instance” inside of information with the extension .txt
inside of ExampleDir
dierctory.
./ExampleDir/file1.txt:That is an Instance line in file1. ./ExampleDir/subdir/file2.txt:Some other Instance in a distinct document. ./ExampleDir/file3.txt:Instance utilization of the to find command.
5. In finding and listing information and sub-directories personal by way of particular consumer
to find ./ExampleDir -user ubuntu
This command, with the -user
parameter, will to find information and sub-directories owned by way of Ubuntu
consumer in ExampleDir
listing. If discovered, the filename(s) will likely be returned.
Within the following pattern ls -l
outcome:
-rw-rw-r-- 1 newone ubuntu 20 Jan 27 06:24 instance.txt
newone
represents organization call, and ubuntu
is the consumer.
6. In finding and listing information and sub-directories personal by way of particular organization
to find ./ExampleDir -group ubuntu
This command, with the -group
paramter, will to find all information and sub-directories owned by way of Ubuntu
organization in ExampleDir
listing. If discovered, the filename(s) will likely be returned.
Extra Linux instructions:
Listing Operations | rmdir · cd · pwd |
Document Operations | cat · cp · dd · much less · ls · mkdir · mv · tail · tar · zip |
Document Machine Operations | chown · mkfs |
Networking | ping · curl · wget · iptables |
Seek and Textual content Processing | to find · grep · sed · whatis |
Machine Data and Control | env · historical past · best · who |
Consumer and Consultation Control | display · su · sudo |
The publish Learn how to In finding Information and Folders in Linux gave the impression first on Hongkiat.
WordPress Website Development Source: https://www.hongkiat.com/blog/linux-command-find/