Finding out the size of directories in Linux

Do you want to know the size of a directory in Linux? Use the du command.

du -sh

Explanation

The du command estimates the space used by a directory.

The options -sh are (from man du):

  -s, --summarize
         display only a total for each argument

  -h, --human-readable
         print sizes in human readable format (e.g., 1K 234M 2G)

To check more than one directory and get the total size of those directories, use

du -sch *

What does the extra option mean?

  -c, --total
         produce a grand total

Include hidden files?

du -sch * .*

Want to know how much disk space has been used?

du -h .
Advertisements

Tradingview Pine Script syntax highlighting for Notepad++

I have been working with Tradingview Pine Scripts (TPS) and it was irritating me that when the scripts get lager and more complex they are hard to read. So I decided to create syntax highlighting for TPS for Notepad++ (NPP). NPP is the go to text editor for Windows. It provides an easy mechanism for adding custom syntax highlighting for languages using its User Defined Language (UDL) functionality.

You can find the the User Defined Language (UDL) file for syntax highlighting Tradingview Pine Scripts (TPS) files in Notepad++ (NPP) in this repository on GitHub.

Let me know what you think and if it is helpful.

Bash shell shortcuts

I have been irritated not having standard keyboard shortcuts, like Ctrl-arrow left (move word left) and Ctrl-arrow right (move word right), available on the bash command line. It turns out they are. If you know what the meta key is. Meta key? Yes, I didn’t know which key this was either.

It turns out that it is the Alt key. This is because historically, many Unix workstations had a key labeled Meta where PCs have a key labeled Alt.

So here is a little bash command line cheat sheet.

  • Ctrl-a: Move to the start of the current line.
  • Ctrl-e: Move to the end of the line.
  • Ctrl-f: Move forward a character.
  • Ctrl-b: Move back a character.
  • Meta-f: Move forward to the end of the next word. Words are composed of letters and digits.
  • Meta-b: Move backward to the start of the next word. Words are composed of letters and digits.

Have fun.

Plugin Manager removed from Notepad++

I needed the compare plugin today. You used to be able to select the Plugin Manager under Plugins -> Plugin Manager. But it was gone 😦 It turns out it has been removed from the standard installation and has to be installed separately. I haven’t been able to find out why. Here quick instructions how to install Plugin Manager.

  • Download the latest version of Plugin Manger from GitHub. Make sure you download the correct version 32 or 64 bit depending on the version of your operating system.
  • Unzip the file.
  • Copy the two directories to the Notepad++ directory. In my case C:\Program Files (x86)\Notepad++.
  • Restart Notepad++.

Plugin Manager is available again under Plugins -> Plugin Manager. Yeah!

Finding out which files are open and by which programs

Grrrrrrr ran into my inotify problem again. So I was wondering how I can see which program has files opened and how many. Well as with everything under Linux it is possible with a few “simple” commands. Try the following command for fun and entertainment.

$ lsof | awk ‘{print $1}’ | sort | uniq -c | sort -g -k 1 | tail

  • lsof: lists the open files
  • awk: takes the first column of the output
  • sort: yep it sorts the output
  • uniq: counts all the same value
  • sort: do you want me to repeat it? a little clarification is necessary -k tells which column to sort on and -g makes sure that the contents is treated like a number
  • tail: gives the last ten entries