Tips tagged sort


3

Tip #828   Sorting debian packages installed by size

The command below will give a list of the packages installed on a debian system sorted from smallest to largest (the order can be reveresed by adding an 'r' option to sort - 'sort -k2 -nr').

Read more »

4

Tip #819   List 10 biggest files in a directory

The commmands below show the ten largest files/dirs in the working directory. Both commands give similar results, though handle things slightly differently. The 'du' option is good if you also need sizes of subdirectories, but the 'ls' option gives more detail.

Read more »

7

Tip #742   Sort the lines of a file by length

The command below can be used to sort the lines of a file by ascending order (shortest first). Change 'sort -n' to 'sort -nr' to sort in descending order (longest first).

Read more »

2

Tip #557   Randomize lines in a file

The bash shell has a variable called $RANDOM, which outputs a pseudo-random number every time you call it. This allows you to randomize the lines in a file for example:

Read more »

3

Tip #528   Top ten running processes

Display the top ten running processes - sorted by memory usage

ps aux | sort -nk +4 | tail

ps returns all running processes which are then sorted by the 4th field in numerical order and the top 10 are sent to STDOUT. Read more »

110

Tip #275   Get an ordered list of subdirectory sizes

This piece of code lists the size of every file and subdirectory of the current directory, much like du -sch ./* except the output is sorted by size, with larger files and directories at the end of the list. Useful to find where all that space goes.

Read more »

0

Tip #259   Ghetto lsof when you don

You might want to get rid of the awk, sort, uniq and grep depending on how much info you need.

Read more »

6

Tip #258   List non-system users

I use the following to list non-system users. It should be portable though won't work on systems without the getent command.

Read more »

12

Tip #247   See your favorite commands

Use the following to see the commands you use most often based on your shell history:

Read more »