Technotes

Technotes for future me

Find

Find Files Using Name in Current Directory

find . -name blaat.txt

./blaat.txt

Find Files Under Home Directory

find /home -name blaat.txt

/home/blaat.txt

Find Files Using Name and Ignoring Case

find /home -iname blaat.txt

./blaat.txt
./Blaat.txt

Find Directories Using Name

find / -type d -name blaat

/blaat

Find PHP Files Using Name

find . -type f -name blaat.php

./blaat.php

Find all PHP Files in the Directory

find . -type f -name "*.php"

./blaat.php
./login.php
./index.php

Find and remove Multiple File

find . -type f -name "*.txt" -exec rm -f {} \;
find . -type f -name "*.mp3" -exec rm -f {} \;

find . -type f -iname "*.txt" -delete

Find and remove Multiple Directories

find . -type d -empty -delete

Find Last 50 Days Modified Files

find / -mtime 50

Find Last 50 Days Accessed Files

find / -atime 50

Source:
https://www.tecmint.com/35-practical-examples-of-linux-find-command/

Last updated on 6 Jun 2024
Published on 6 Sep 2021
Edit on GitHub