Skip to main content
ubuntuask.com

Back to all posts

How to Compare Folders Size In Bash/Sh?

Published on
3 min read
How to Compare Folders Size In Bash/Sh? image

Best Folder Comparison Tools to Buy in October 2025

1 Devvicoo 17 PCS Metal File Set Upgraded Hemicycle, Angle, Round, Flat & Needle Files for Plastic, Wood, Metal Projects - Alloy Steel Hand Tools with Storage Case

Devvicoo 17 PCS Metal File Set Upgraded Hemicycle, Angle, Round, Flat & Needle Files for Plastic, Wood, Metal Projects - Alloy Steel Hand Tools with Storage Case

  • DURABLE T12 ALLOY STEEL: LONG-LASTING FILES FOR ALL CRAFTING NEEDS.

  • VERSATILE FILE KIT: 16 FILES FOR PRECISION IN DIVERSE PROJECTS.

  • ERGONOMIC DESIGN: COMFORTABLE GRIPS REDUCE FATIGUE FOR EXTENDED USE.

BUY & SAVE
$14.99
Devvicoo 17 PCS Metal File Set Upgraded Hemicycle, Angle, Round, Flat & Needle Files for Plastic, Wood, Metal Projects - Alloy Steel Hand Tools with Storage Case
2 Small Hand Files Set for Detail and Precise Work, Hardened Alloy Strength Steel File Tools Includes Square,Equaling,Round,Flat Warding,Triangle

Small Hand Files Set for Detail and Precise Work, Hardened Alloy Strength Steel File Tools Includes Square,Equaling,Round,Flat Warding,Triangle

  • DURABLE CARBON STEEL WITH UP TO 66HRC FOR LASTING CUTTING POWER.
  • ERGONOMIC RUBBER HANDLE ENSURES COMFORT DURING EXTENDED USE.
  • VERSATILE FOR PRECISE FILING ON WOOD, METAL, GLASS, AND MORE.
BUY & SAVE
$4.49
Small Hand Files Set for Detail and Precise Work, Hardened Alloy Strength Steel File Tools Includes Square,Equaling,Round,Flat Warding,Triangle
3 REXBETI 25Pcs Metal File Set, Premium Grade T12 Drop Forged Alloy Steel, Flat/Triangle/Half-round/Round Large File and 12pcs Needle Files with Carry Case, 6pcs Sandpaper, Brush, A Pair Working Gloves

REXBETI 25Pcs Metal File Set, Premium Grade T12 Drop Forged Alloy Steel, Flat/Triangle/Half-round/Round Large File and 12pcs Needle Files with Carry Case, 6pcs Sandpaper, Brush, A Pair Working Gloves

  • DURABLE T12 DROP FORGED ALLOY STEEL FOR LASTING PERFORMANCE.
  • COMPLETE 25-PIECE SET WITH GLOVES, SANDPAPER, AND CARRY CASE.
  • ERGONOMIC LONG HANDLE FOR COMFORTABLE, EXTENDED USE.
BUY & SAVE
$22.09 $25.99
Save 15%
REXBETI 25Pcs Metal File Set, Premium Grade T12 Drop Forged Alloy Steel, Flat/Triangle/Half-round/Round Large File and 12pcs Needle Files with Carry Case, 6pcs Sandpaper, Brush, A Pair Working Gloves
4 HORUSDY 6-Pieces Needle File Set, Hand Metal Files, Alloy Strength Steel Include Flat, Flat Warding, Square, Triangular, Round, and Half-Round File.

HORUSDY 6-Pieces Needle File Set, Hand Metal Files, Alloy Strength Steel Include Flat, Flat Warding, Square, Triangular, Round, and Half-Round File.

  • DURABLE HIGH HARDNESS ALLOY STEEL FOR LONG-LASTING PERFORMANCE.
  • VERSATILE SIX-PIECE SET FOR A WIDE RANGE OF APPLICATIONS.
  • ERGONOMIC HANDLE DESIGN ENSURES COMFORT AND SUPERIOR CONTROL.
BUY & SAVE
$7.99
HORUSDY 6-Pieces Needle File Set, Hand Metal Files, Alloy Strength Steel Include Flat, Flat Warding, Square, Triangular, Round, and Half-Round File.
5 Hurricane 21 PCS Interchangeable Metal File Set,8 inch File Tool Set Include Flat/Triangle/Half-Round/Round Large Files & 12 Needle Files with Universal Quick Change Handles and Carrying Bag

Hurricane 21 PCS Interchangeable Metal File Set,8 inch File Tool Set Include Flat/Triangle/Half-Round/Round Large Files & 12 Needle Files with Universal Quick Change Handles and Carrying Bag

  • VERSATILE 21-PIECE SET FOR EVERY FILING TASK AND MATERIAL.

  • ERGONOMIC QUICK-CHANGE HANDLE: COMFORT MEETS CONVENIENCE.

  • PREMIUM T12 STEEL FOR LONG-LASTING, PRECISE CUTTING POWER.

BUY & SAVE
$13.99
Hurricane 21 PCS Interchangeable Metal File Set,8 inch File Tool Set Include Flat/Triangle/Half-Round/Round Large Files & 12 Needle Files with Universal Quick Change Handles and Carrying Bag
6 17Pcs File Tool Set with Carry Case,Premium Grade T12 Drop Forged Alloy Steel, Precision Flat/Triangle/Half-round/Round Large File and 12pcs Needle Files/1 brush

17Pcs File Tool Set with Carry Case,Premium Grade T12 Drop Forged Alloy Steel, Precision Flat/Triangle/Half-round/Round Large File and 12pcs Needle Files/1 brush

BUY & SAVE
$17.99 $20.99
Save 14%
17Pcs File Tool Set with Carry Case,Premium Grade T12 Drop Forged Alloy Steel, Precision Flat/Triangle/Half-round/Round Large File and 12pcs Needle Files/1 brush
7 Hi-Spec 17 Piece Metal Hand & Needle File Tool Kit Set. Large & Small Mini T12 Carbon Steel Flat, Half-Round, Round & Triangle Files. Complete in a Zipper Case with a Brush

Hi-Spec 17 Piece Metal Hand & Needle File Tool Kit Set. Large & Small Mini T12 Carbon Steel Flat, Half-Round, Round & Triangle Files. Complete in a Zipper Case with a Brush

  • COMPLETE FILING SET: 4 MACHINIST FILES & 12 NEEDLE FILES FOR EVERY TASK.

  • BUILT TO LAST: T12 CARBON STEEL ENSURES DURABILITY AND LONG-LASTING USE.

  • TIGHT SPOT MASTERY: NEEDLE FILES OFFER PRECISION FOR INTRICATE AND DETAILED WORK.

BUY & SAVE
$24.99
Hi-Spec 17 Piece Metal Hand & Needle File Tool Kit Set. Large & Small Mini T12 Carbon Steel Flat, Half-Round, Round & Triangle Files. Complete in a Zipper Case with a Brush
8 TARIST 12PCS Needle File Set with Tool Bag, Small File Set Includes 6pcs Jewlers Files & 6 Steel Files for Metal, Jewlers, Wood, Leather and Plastic

TARIST 12PCS Needle File Set with Tool Bag, Small File Set Includes 6pcs Jewlers Files & 6 Steel Files for Metal, Jewlers, Wood, Leather and Plastic

  • DURABLE CARBON STEEL WITH QUENCHED TEETH FOR LONG-LASTING PERFORMANCE.
  • VERSATILE: PERFECT FOR METAL, WOOD, GLASS, AND MORE APPLICATIONS.
  • RELIABLE AFTER-SALES SUPPORT ENSURES YOUR SATISFACTION WITHIN 24 HOURS.
BUY & SAVE
$14.39 $19.80
Save 27%
TARIST 12PCS Needle File Set with Tool Bag, Small File Set Includes 6pcs Jewlers Files & 6 Steel Files for Metal, Jewlers, Wood, Leather and Plastic
9 LIBRATON Small File Set, Needle Diamond Files 13PCS, 6pcs Jewlers & 6 Steel for Precision Metal Work, Wood, Woodworking, Plastic Carving Tool with Brush and Carry Case

LIBRATON Small File Set, Needle Diamond Files 13PCS, 6pcs Jewlers & 6 Steel for Precision Metal Work, Wood, Woodworking, Plastic Carving Tool with Brush and Carry Case

  • LONG-LASTING HIGH CARBON STEEL FOR SUPERIOR DURABILITY AND STRENGTH.

  • ERGONOMIC NON-SLIP RUBBER HANDLES FOR MAXIMUM COMFORT AND CONTROL.

  • VERSATILE MINI FILES FOR MULTIPLE APPLICATIONS: WOOD, METAL, PLASTIC.

BUY & SAVE
$16.95
LIBRATON Small File Set, Needle Diamond Files 13PCS, 6pcs Jewlers & 6 Steel for Precision Metal Work, Wood, Woodworking, Plastic Carving Tool with Brush and Carry Case
+
ONE MORE?

To compare folder sizes in bash/sh, you can use the du command to display the size of each folder in bytes. You can also use a combination of du and sort commands to list the folders in descending order of size. Another option is to use the awk command to sum up the sizes of all folders and then compare them using conditional statements. By using these commands and techniques, you can easily compare folder sizes in bash/sh and determine which folder is larger or smaller.

What is the best way to compare folders size in bash?

One way to compare folder sizes in bash is by using the du (disk usage) command to display the size of each folder and then comparing the sizes using conditional statements.

For example, you can use the following script to compare the sizes of two folders:

size_folder1=$(du -s folder1 | cut -f1) size_folder2=$(du -s folder2 | cut -f1)

if [ $size_folder1 -gt $size_folder2 ]; then echo "Folder 1 is larger" elif [ $size_folder1 -lt $size_folder2 ]; then echo "Folder 2 is larger" else echo "Folders are the same size" fi

This script uses the du -s command to get the size of each folder and the cut command to extract only the size value. It then compares the sizes and prints out a message indicating which folder is larger.

What is the syntax for comparing folders size using du command in bash?

To compare the size of two folders using the du command in bash, you can use the following syntax:

du -sh folder1 folder2

This command will display the total size of both folder1 and folder2 in a human-readable format, allowing you to compare the sizes of the two folders.

How to compare multiple folders sizes in bash?

One way to compare multiple folders sizes in bash is to use the du (disk usage) command to get the size of each folder and then use a loop to iterate over each folder and compare their sizes.

Here is an example script that compares the sizes of multiple folders:

#!/bin/bash

List of folders to compare

folders=(/path/to/folder1 /path/to/folder2 /path/to/folder3)

Iterate over each folder

for folder in "${folders[@]}" do size=$(du -sh "$folder" | cut -f1) echo "Size of $folder: $size" done

This script will output the size of each folder in the folders array. You can modify the script to compare the sizes and perform any desired actions based on the comparison results.