I just noticed that some of the MySQL files on this website had grown very large, so I wanted to be able to list all of the files in the MySQL data directory and sort them by filesize, with the largest files shown at the end of the listing. This
ls command did the trick, resulting in the output shown in the image:
-S option is the key, telling the
ls command to sort the file listing by size. The
-h option tells
ls to make the output human readable, and
-r tells it to reverse the output, so in this case the largest files are shown at the end of the output.
I haven’t solved my overall problem yet — which is how to fit 64 GB of music onto a tablet with 24GB free space — but I did solve another problem today: How to show the largest files under a directory on Mac OS X (and Unix systems). In this short tutorial I’ll demonstrate what I learned.
A command to show the largest files under a directory on Mac OS X
The Unix command that worked for me on my Mac OS X system is this:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.28, “How to Use Sortable Sets in Scala”
You want to be able to store and retrieve items from a set in a sorted order.
To retrieve values from a set in sorted order, use a
SortedSet. To retrieve elements from a set in the order in which elements were inserted, use a
SortedSet returns elements in a sorted order:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 11.23, “How to Sort an Existing Map by Key or Value”
You have an unsorted map and want to sort the elements in the map by the key or value.
Given a basic, immutable
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is one of the shortest recipes in the book, Recipe 11.10, “How to Sort Arrays in Scala”
You want to sort the elements in an
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.28, “How to Sort a Scala Collection”
You want to sort a sequential collection. Or, you want to implement the
Ordered trait in a custom class so you can use the sorted method, or operators like
>= to compare instances of your class.
To create an order by query using the
find method of the MongoDB Casbah driver (Scala), use the
sort method, as shown in this example:
Scala List FAQ: Can you share some Scala List class examples?
The Scala List class may be the most commonly used data structure in Scala applications. Therefore, it's very helpful to know how create lists, merge lists, select items from lists, operate on each element in a list, and so on.
In this tutorial, I'll try to share examples of the most common List operations (methods).
If you're ever working on a Unix or Linux system, and have a list with duplicated items in it, and want a smaller list of only the unique items in the list, the sort command is your friend.
I just ran into a situation where I generated a list of fonts on a Mac OS X (Unix) system, and my list ended up with a bunch of duplicated names, like this: