0
0
Linux CLIscripting~20 mins

find by modification time in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Find Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Find files modified exactly 3 days ago
What is the output of this command if the directory contains files modified 1, 3, and 5 days ago?

find . -type f -mtime 3
Linux CLI
find . -type f -mtime 3
ALists only files modified exactly 3 days ago
BLists files modified more than 3 days ago
CLists files modified within the last 3 days
DLists files modified less than 3 days ago
Attempts:
2 left
💡 Hint
Remember, '-mtime n' matches files modified exactly n days ago.
💻 Command Output
intermediate
1:30remaining
Find files modified less than 7 days ago
What does this command list?

find /tmp -type f -mtime -7
Linux CLI
find /tmp -type f -mtime -7
AFiles modified between 7 and 14 days ago
BFiles modified exactly 7 days ago
CFiles modified more than 7 days ago
DFiles modified less than 7 days ago
Attempts:
2 left
💡 Hint
The minus sign before 7 means less than 7 days.
💻 Command Output
advanced
1:30remaining
Find files modified more than 10 days ago
What output will this command produce?

find /var/log -type f -mtime +10
Linux CLI
find /var/log -type f -mtime +10
AFiles modified less than 10 days ago
BFiles modified exactly 10 days ago
CFiles modified more than 10 days ago
DFiles modified between 5 and 10 days ago
Attempts:
2 left
💡 Hint
The plus sign means strictly greater than the number of days.
🔧 Debug
advanced
2:00remaining
Why does this find command fail to list files modified in last 2 days?
You run:

find . -type f -mtime 2

but it does not list files modified yesterday. Why?
Linux CLI
find . -type f -mtime 2
ABecause '-mtime 2' matches files modified exactly 2 days ago, not less
BBecause '-mtime 2' matches files modified less than 2 days ago
CBecause '-mtime 2' matches files modified more than 2 days ago
DBecause '-mtime 2' matches files modified within last 2 days
Attempts:
2 left
💡 Hint
Check how '-mtime n' works with exact days.
🚀 Application
expert
2:30remaining
Find and delete files older than 30 days safely
Which command safely finds and deletes files older than 30 days in /home/user/tmp?
Afind /home/user/tmp -type f -mtime +30 | xargs rm
Bfind /home/user/tmp -type f -mtime +30 -delete
Cfind /home/user/tmp -type f -mtime +30 -exec rm -rf {} \;
Dfind /home/user/tmp -type f -mtime +30 -exec rm {} \;
Attempts:
2 left
💡 Hint
Use the safest and simplest way to delete files with find.