Find command with some examples

by admin October 8, 2016 at 4:12 pm

Find command is available by default in most of the Linux distros so you don’t need to install any packages to get this command. Find command is very useful to search it for a particular file based on various search criteria like permissions, ownership, modifcation of date/time etc., Using find command even you can search it for specific files and remove it. We will see below with some examples of Find command.

1. Finding files with particular extension.

# find /etc/ -type -f -name "*.conf"

2. Finding files using the name in current directory

# find . -name "test.txt"

3. Find and remove zero size files

Removing the zero byte files in current directory.

# find . -size 0 -exec rm {} \;

Find and remove the zero byte files in /tmp directory

# find /tmp -size 0 -exec rm {} \;

Add Comment