Use the find command in Linux to look for multiple file types at once.

The Linux find command is useful for finding files on your Linux system. It is possible to look for more than one file type.

This example will search for all text and png files under the /usr/share directory.

[email protected]:/usr/share$ find -regex '.*txt\|.*png'

This example will search for three different file types.

[email protected]:/usr/share$ find -regex '.*txt\|.*png\|.*gz'

Use wildcards like this to find specific file types.

[email protected]:/usr/share/doc$ find . -name \*.gz -print

search only 2 levels deep into directories to find a certain file.

root@neo:/home/jason# find / -maxdepth 2 -name "meminfo"

Use the find command to find all files that changed in the past 5 minutes.

root@neo:/home/jason# find / -maxdepth 2 -cmin 5

The locate command is another way to find files on your filesystem. In this example, I am finding all files in the / directory that are named vmlinux.

root@neo:/home/jason# locate vmlinux

Find the space hogging files on your Linux system.

[email protected]:~$ lsof / | awk '{if($7 > 1048576) print $7/1048576 "MB" " " $9 }' | sort -n -u | tail
3.61054MB /usr/bin/python2.7
4.29156MB /usr/lib/x86_64-linux-gnu/
4.29343MB /usr/lib/x86_64-linux-gnu/
5.66222MB /usr/lib/x86_64-linux-gnu/
6.70585MB /usr/lib/x86_64-linux-gnu/
6.91679MB /usr/lib/x86_64-linux-gnu/
7.79662MB /usr/lib/x86_64-linux-gnu/dri/
22.4236MB /usr/lib/x86_64-linux-gnu/
29.0516MB /usr/lib/x86_64-linux-gnu/
31.6988MB /usr/lib/x86_64-linux-gnu/

No comments have been made. Use this form to start the conversation :)

Leave a Reply