Skip to content
Fix Code Error

Using ls to list directories and their total sizes

March 13, 2021 by Code Error
Posted By: Anonymous

Is it possible to use ls in Unix to list the total size of a sub-directory and all its contents as opposed to the usual 4K that (I assume) is just the directory file itself?

total 12K
drwxrwxr-x  6 *** *** 4.0K 2009-06-19 10:10 branches
drwxrwxr-x 13 *** *** 4.0K 2009-06-19 10:52 tags
drwxrwxr-x 16 *** *** 4.0K 2009-06-19 10:02 trunk

After scouring the man pages I’m coming up empty.

Solution

Try something like:

du -sh *

short version of:

du --summarize --human-readable *

Explanation:

du: Disk Usage

-s: Display a summary for each specified file. (Equivalent to -d 0)

-h: “Human-readable” output. Use unit suffixes: Byte, Kibibyte (KiB), Mebibyte (MiB), Gibibyte (GiB), Tebibyte (TiB) and Pebibyte (PiB). (BASE2)

Answered By: Anonymous

Related Articles

  • Design DFA accepting binary strings divisible by a…
  • Apache server keeps crashing, "caught SIGTERM,…
  • Easy interview question got harder: given numbers…
  • useEffect Error: Minified React error #321 (GTM…
  • Having trouble with my nav bar/header, It used to…
  • Circle line-segment collision detection algorithm?
  • Get a list of dates between two dates
  • Examples of GoF Design Patterns in Java's core libraries
  • Start redis-server with config file
  • Reversing a string in C
  • How to prevent scrolling the whole page?
  • How to properly do JSON API GET requests and assign…
  • Active tab issue on page load HTML
  • Maven parent pom vs modules pom
  • How to fetch all Git branches
  • What are the undocumented features and limitations…
  • How to properly create an SVN tag from trunk?
  • Why does git perform fast-forward merges by default?
  • Push git commits & tags simultaneously
  • Checkout another branch when there are uncommitted…
  • Why do git fetch origin and git fetch : behave differently?
  • bootstrap-datepicker in dd/mm/yyyy - selected date…
  • C# Net.Core Object.Equals() returning false even if…
  • Text size and different android screen sizes
  • Does "git fetch --tags" include "git fetch"?
  • How can I see the size of files and directories in linux?
  • How do I establish a link/relationship between objects?
  • What is git tag, How to create tags & How to…
  • What's the difference between git clone --mirror and…
  • How to initialize a list with constructor?
  • python 3.2 UnicodeEncodeError: 'charmap' codec can't…
  • How to display gpg key details without importing it?
  • SASS Function Reduce Line Height as Font Size Increases
  • while loop is not running correctly according to…
  • What do "branch", "tag" and "trunk" mean in…
  • Fastest way to iterate over all the chars in a String
  • Remove tracking branches no longer on remote
  • The definitive guide to form-based website authentication
  • R: "Unary operator error" from multiline ggplot2 command
  • ExpressJS How to structure an application?
  • javascript .replace and .trim not working in vuejs
  • Merge a Branch into Trunk
  • Using JsonConvert.DeserializeObject to deserialize…
  • Throw HttpResponseException or return…
  • git remote prune – didn't show as many pruned…
  • Which icon sizes should my Windows application's…
  • data.table vs dplyr: can one do something well the…
  • Memcached vs. Redis?
  • Calculate the mean by group
  • collision detection from picturebox in a list c#
  • Is it possible to apply CSS to half of a character?
  • How do I discover memory usage of my application in Android?
  • Merge trunk to branch in Subversion
  • What is trunk, branch and tag in Subversion?
  • HTML 5 Favicon - Support?
  • How does database indexing work?
  • Neither BindingResult nor plain target object for…
  • Android Camera Preview Stretched
  • Polymer switch between nested templates via 2-way binding
  • Virtual Memory Usage from Java under Linux, too much…
  • How can I avoid Java code in JSP files, using JSP 2?
  • Should I use px or rem value units in my CSS?
  • Unresponsive hamburger icon in HTML
  • Maven2: Missing artifact but jars are in place
  • Git submodule head 'reference is not a tree' error
  • How do I install Java on Mac OSX allowing version switching?
  • Efficiency of Java "Double Brace Initialization"?
  • Vaadin: Tabs are displayed in a really bizarre way -…
  • Correct way to convert size in bytes to KB, MB, GB…
  • 'Missing recommended icon file - The bundle does not…
  • How to list branches that contain a given commit?
  • How is Perl's @INC constructed? (aka What are all…
  • VBA get a list of files in folder and their tags (Keywords)
  • Shell Script Syntax Error: Unexpected End of File
  • Sort a two dimensional array based on one column
  • Complex nesting of partials and templates
  • svn : how to create a branch from certain revision of trunk
  • Ember Data hasMany async observed property "simple" issue
  • How do I expand the output display to see more…
  • “tag already exists in the remote" error after…
  • Is it possible to style different sections of…
  • Java Array, Finding Duplicates
  • What is your most productive shortcut with Vim?
  • Use of String.Format in JavaScript?
  • Show/hide 'div' using JavaScript
  • iron-pages: Page Changed Event
  • How to Free Inode Usage?
  • Saving data to a file in C#
  • Generating swagger for Dictionary
  • Smart way to truncate long strings
  • how to list all sub directories in a directory
  • How to horizontally align ul to center of div?
  • High Quality Image Scaling Library
  • Error message "Forbidden You don't have permission…
  • Mysql Compare two datetime fields
  • Why call git branch --unset-upstream to fixup?
  • Git Using Remote Branch
  • Route's Model Hook with Ember Data "filter" not…
  • What is a tracking branch?
  • Xcode error "Could not find Developer Disk Image"

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Split string on whitespace in Python

Next Post:

How can I open a cmd window in a specific location?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error