0
0
Linux CLIscripting~30 mins

find by name, type, and size in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Find Files by Name, Type, and Size Using Linux CLI
📖 Scenario: You are organizing files on your Linux system. You want to find files based on their name, type, and size to manage storage efficiently.
🎯 Goal: Build a Linux command using find to search files by exact name, file type, and minimum size.
📋 What You'll Learn
Use the find command
Search for files with a specific name
Filter by file type (regular file or directory)
Filter files by minimum size
💡 Why This Matters
🌍 Real World
System administrators and users often need to find files quickly based on specific criteria to manage disk space or organize data.
💼 Career
Knowing how to use the <code>find</code> command with filters is essential for Linux system administration, scripting, and automation tasks.
Progress0 / 4 steps
1
Create a directory with files for testing
Create a directory called test_dir and inside it create three files named report.txt, data.csv, and summary.log.
Linux CLI
Need a hint?

Use mkdir to create a directory and touch to create empty files.

2
Add a size filter variable
Create a variable called min_size and set it to 1k to represent minimum file size of 1 kilobyte.
Linux CLI
Need a hint?

Assign min_size=1k to set the size filter.

3
Write the find command with name, type, and size filters
Write a find command to search in test_dir for regular files named report.txt with size greater than or equal to $min_size.
Linux CLI
Need a hint?

Use find . -type f -name report.txt -size +$min_size to filter files.

4
Display the result of the find command
Run the find command from Step 3 and print the output to show the matching files.
Linux CLI
Need a hint?

The output should show ./report.txt if the file matches the criteria.