find command in linux

2 Answer(s)

 

Find all the files whose name is eduguru.txt in a current working directory.

# find . -name eduguru.txt

./eduguru.txt

Find all the files under /home directory with name eduguru.txt.

# find /home -name eduguru.txt

/home/eduguru.txt

Find all the files whose name is eduguru.txt and contains both capital and small letters in /home directory.

# find /home -iname eduguru.txt

./eduguru.txt
./EDUguru.txt

Find all directories whose name is Eduguru in / directory.

# find / -type d -name Eduguru

/Eduguru

Find all php files whose name is eduguru.php in a current working directory.

# find . -type f -name eduguru.php

./eduguru.php

Find all php files in a directory.

# find . -type f -name “*.php”

./eduguru.php
./login.php
./index.php

Find all the files whose permissions are 777.

# find . -type f -perm 0777 -print

Find all the files without permission 777.

# find / -type f ! -perm 777

To find all empty files under certain path.

# find /tmp -type f -empty

To file all empty directories under certain path.

# find /tmp -type d -empty

To find and remove multiple files such as .mp3 or .txt, then use.

# find . -type f -name “*.txt” -exec rm -f {} \;

OR

# find . -type f -name “*.mp3” -exec rm -f {} \;

To find all the files which are modified 50 days back.

# find / -mtime 50

o find all the files which are accessed 50 days back.

# find / -atime 50

To find all the files which are modified more than 50 days back and less than 100 days.

# find / -mtime +50 –mtime -100

To find all the files which are changed in last 1 hour.

# find / -cmin -60

To find all the files which are modified in last 1 hour.

# find / -mmin -60

To find all the files which are accessed in last 1 hour.

# find / -amin -60

To find all 50MB files, use.

# find / -size 50M

To find all the files which are greater than 50MB and less than 100MB.

# find / -size +50M -size -100M

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

# find / -type f -size +100M -exec rm -f {} \;

 

https://blog.eduguru.in/tag/find-command-in-linux

Answered on January 25, 2020.
Add Comment
Answered on January 25, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.