Using Find Command Part Three

0
120
Using Find Command Part Three

Using Find Command Part Three

Using find command part three. I will link the previous two articles about find command. The find command is used to search for files and directories in the hierarchy tree on the command line. Fin is one of the most useful commands and also provides some addition functionalities using test operations.

Find files by the time of access, modification or change of files.

Find based on the modification.

The above Find command will list all the files in the current working directory till the bottom of the hierarchy who was modified 10 days before.

The Files which was modified in between 10 to 50 days.

The mtime option searches the files in days and mmin option searches the files in minutes. The above command will search for files which were modified in last 60 minutes.

Find files changed within the last 60 minutes.

To find all the files which are accessed 10 days.

Find Accessed Files in Last 60 min

 

Search multiple directories

The find command can also be used to search in two different directories

The above find command will find all the files named filename from both the directories.

 

Combined Operations.

the find command can also be used with multiple test operation to get better-filtered results.

if we want a file named lincoder and there are some additional files which are named like lincoder.txt, lincoder.c, but we want only the file lincoder.

The above find command looks for files named lincoder which doesn’t have any extension.

When we use multiple test condition, by default the AND operation is used (i.e both the operation will be executed). However, we can also provide an OR operation by using the -o option.

The above command searches for files ending in either the txt extension or the c extension.

 

Find command using with exec.

To find all 100MB files and delete them using one single command.

Find all .png files with more than 10MB and delete them using one single command.

The find command, when used in combination with the ls and sort command, can be used to list out the largest files.

The following command will display the largest files in the current directory and its subdirectory.

Similarly, when sorted in ascending order, it would show the smallest files first

For more information required about find and options read the man page from one of the following links.

find(1)          find(2)          find(3)          find(4)

That’s it, we are at the end of the article using find command part three. Have any question?
Feel free to ask them in the comments below. Stay tuned for more updates.

SHARE
Previous articleUsing Find Command Part Two
Next articleShow Presentation From Linux Terminal
arunvkumr@gmail.com'
Arun is Open Source Enthusiast. He likes to spend most of his time exploring linux distribution, solving puzzles and coding.

LEAVE A REPLY