Last Blog Review →
In the last, blog we understood how awk is such a powerful programming tool which is used as a text processor which means it’s used for extracting the data and manipulating it. Arithmetic operations can be performed like sum, avg, mul, div. Support’s arrays as well. Pattern matching for advanced regex text. Also supports data filtering and transformation.
What is Find in Linux ?
Find is one of the most important and used command in Linux
Find command is used to search and locate list of files and directories based on condition you specify for files that match the arguments.
Find command can be used in variety of conditions like you can use to find files by permission’s, user’s, group’s, file type, date, size, etc.
Let’s understand it practically looking at the commands
To find files under home directory -
The below command will find the file type have extension as “docx” in home direcctory
find /home -type f -name "*.docx"
To find files with suid permission
find / -type f -perm /4000
To find files with guid permission
find / -type f -perm /2000
To find files with sticky bit permission
find / -type f -perm /1000
Using find command based on user’s
The
find
command in Linux can be used to search for files and directories based on the owner (user). You can use the-user
option to filter results by user.find / -user mihir
Using find command based on groups
find / -group mihirgro
Search the file which is less that 10MB
find / -type f -size -10M
Search the file which is more that 10MB
find / -type f -size +10M
Conclusion →
So, here you saw how to use “Find” command in linux, which makes the life easy as there are lot of files and directories in linux because being a inversted tree like structure, it’s very difficult to find a particular find due to which using this command we can get the desired files and directories quickly within no time. As Find allows you to use many filter’s to search the file and directories as we saw above.
Image credit - https://images.app.goo.gl/bgKS3FYdCBcTgRVy8