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 March 2026

1 Ymapinc 6 Pcs Folder Paper Creaser Set Bone Folders, Scoring Tool, Paper Creaser, Origami Tools for Handmade Scrapbooking Bookbinding Paper Cards Crafts Leather Burnishing

Ymapinc 6 Pcs Folder Paper Creaser Set Bone Folders, Scoring Tool, Paper Creaser, Origami Tools for Handmade Scrapbooking Bookbinding Paper Cards Crafts Leather Burnishing

  • VERSATILE 6-PIECE KIT FOR ALL YOUR CRAFTING NEEDS AND PROJECTS.

  • MULTIPLE SHAPES ENHANCE PRECISION IN ORIGAMI, SEWING, AND BOOKBINDING.

  • LIGHTWEIGHT, DURABLE DESIGN ENSURES COMFORT FOR LONG CRAFTING SESSIONS.

BUY & SAVE
$5.79
Ymapinc 6 Pcs Folder Paper Creaser Set Bone Folders, Scoring Tool, Paper Creaser, Origami Tools for Handmade Scrapbooking Bookbinding Paper Cards Crafts Leather Burnishing
2 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

  • DURABLE HIGH CARBON STEEL ENSURES LONG-LASTING PERFORMANCE AND STRENGTH.

  • ERGONOMIC RUBBER HANDLES PROVIDE COMFORT AND NON-SLIP CONTROL DURING USE.

  • VERSATILE MINI FILE DESIGNS FOR VARIOUS APPLICATIONS IN DIFFERENT MATERIALS.

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
3 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

  • PREMIUM STEEL ENSURES SUPERIOR STRENGTH AND LASTING ABRASION RESISTANCE.
  • VERSATILE 17-PIECE KIT CATERS TO ALL YOUR FILING NEEDS AND PROJECTS.
  • COMFORTABLE HANDLES AND PORTABLE BAG ENHANCE CONVENIENCE AND USABILITY.
BUY & SAVE
$18.99
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
4 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

  • PREMIUM CARBON STEEL ENSURES DURABILITY AND HIGH-PERFORMANCE FILING.
  • VERSATILE USE ON METAL, WOOD, GLASS, AND MORE FOR EVERY PROJECT.
  • EXCEPTIONAL AFTER-SALES SUPPORT GUARANTEES YOUR SATISFACTION.
BUY & SAVE
$15.99 $19.80
Save 19%
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
5 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

  • VERSATILE FILING SET FOR METAL, WOOD & PLASTICS: TACKLE ANY TASK EFFORTLESSLY.
  • DURABLE T12 STEEL CONSTRUCTION: ENSURES LONG-LASTING PERFORMANCE AND TOUGHNESS.
  • PRECISION NEEDLE FILES FOR TIGHT SPACES: PERFECT 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
6 KALIM Needle File Set (10Pcs High Carbon Steel Files) and 1 Wire Cutter in A Carry Bag, File Tools for Soft Metal, Wood, Jewelry, Model, DIY, Hobby, etc.

KALIM Needle File Set (10Pcs High Carbon Steel Files) and 1 Wire Cutter in A Carry Bag, File Tools for Soft Metal, Wood, Jewelry, Model, DIY, Hobby, etc.

  • VERSATILE SET: 10 PRECISION NEEDLE FILES & MINI WIRE CUTTER IN ONE KIT.
  • PERFECT FOR DETAIL: HIGH CARBON STEEL FILES ENABLE DELICATE, ACCURATE WORK.
  • IDEAL GIFT CHOICE: COMES WITH A STORAGE CASE FOR CONVENIENCE AND GIFTING.
BUY & SAVE
$8.99 $12.99
Save 31%
KALIM Needle File Set (10Pcs High Carbon Steel Files) and 1 Wire Cutter in A Carry Bag, File Tools for Soft Metal, Wood, Jewelry, Model, DIY, Hobby, etc.
7 KALIM 10PCS Needle File Set High Carbon Steel File Set with Plastic Non-Slip Handle, Hand Metal Tools for Wood, Plastic, Model, Jewelry, Musical Instrument and DIY (6 Inch Total Length)

KALIM 10PCS Needle File Set High Carbon Steel File Set with Plastic Non-Slip Handle, Hand Metal Tools for Wood, Plastic, Model, Jewelry, Musical Instrument and DIY (6 Inch Total Length)

BUY & SAVE
$8.99
KALIM 10PCS Needle File Set High Carbon Steel File Set with Plastic Non-Slip Handle, Hand Metal Tools for Wood, Plastic, Model, Jewelry, Musical Instrument and DIY (6 Inch Total Length)
8 Tsubosan Hand tool Workmanship file set of 5 ST-06 from Japan

Tsubosan Hand tool Workmanship file set of 5 ST-06 from Japan

  • DURABLE CONSTRUCTION FOR LONG-LASTING PERFORMANCE AND PRECISION.
  • ERGONOMIC DESIGN ENSURES COMFORTABLE GRIP AND EASY HANDLING.
  • VERSATILE TOOL SUITABLE FOR VARIOUS MATERIALS AND PROJECTS.
BUY & SAVE
$32.50
Tsubosan Hand tool Workmanship file set of 5 ST-06 from Japan
9 SETTECH 31PCS Metal & Wood File Rasp Set, Half-Round/Round/Triangle/Flat 4pcs Large Tools, 14pcs Needle Files and a Pair of Electric Files, 1PC Brush, 1PC Working Gloves and 10PCS Emery Papers

SETTECH 31PCS Metal & Wood File Rasp Set, Half-Round/Round/Triangle/Flat 4pcs Large Tools, 14pcs Needle Files and a Pair of Electric Files, 1PC Brush, 1PC Working Gloves and 10PCS Emery Papers

  • COMPREHENSIVE 31-PIECE SET: INCLUDES PRECISION FILES, GLOVES, AND STORAGE.

  • DURABLE & COMFORTABLE DESIGN: NON-SLIP HANDLE ENSURES A SECURE GRIP.

  • VERSATILE FOR MANY PROJECTS: IDEAL FOR WOODWORKING, METALWORK, AND MORE.

BUY & SAVE
$24.99
SETTECH 31PCS Metal & Wood File Rasp Set, Half-Round/Round/Triangle/Flat 4pcs Large Tools, 14pcs Needle Files and a Pair of Electric Files, 1PC Brush, 1PC Working Gloves and 10PCS Emery Papers
+
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.