Bird
0
0

You want to create a Bash script that counts how many files in the current directory have a size greater than 1MB. Which command pipeline correctly achieves this?

hard📝 Application Q9 of 15
Linux CLI - Linux Basics and Terminal
You want to create a Bash script that counts how many files in the current directory have a size greater than 1MB. Which command pipeline correctly achieves this?
Als -l | grep '>1M' | wc -l
Bfind . -type f -size +1M | wc -l
Cdu -h | grep '1M' | wc -l
Dstat * | grep size | wc -l
Step-by-Step Solution
Solution:
  1. Step 1: Understand file size filtering

    The find command can filter files by size using -size +1M for files larger than 1MB.
  2. Step 2: Count matching files

    Piping to wc -l counts the number of lines, which equals the number of files found.
  3. Final Answer:

    find . -type f -size +1M | wc -l -> Option B
  4. Quick Check:

    Use find with size filter and count lines [OK]
Quick Trick: Use find -size +1M to filter large files [OK]
Common Mistakes:
MISTAKES
  • Using ls or du incorrectly for size filtering
  • Misusing grep for sizes
  • Counting wrong output lines

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes