Pem: Manage Your Personal Expenses from the Command Line

While expense management is a critical task, both for businesses and individuals, it generally requires you to use a GUI-based software. If you’re a command line geek who is looking for a CLI-based alternative, you should give pem a try. In this article, we will discuss the command line tool, along with the features it provides.

Note: all the examples discussed in this article are tested on Ubuntu 14.04.

The easiest way (that I found) to install the tool is by downloading the package from its official website, building it from source, and then installing it. Here are the steps:

wget http://ftp.gnu.org/gnu/pem/pem-0.7.9.tar.gz
tar -xzvf pem-0.7.9.tar.gz
cd pem-0.7.9
./configure
make
sudo make install

An important point worth mentioning here is that instead of using wget (the first step), you can head to the GNU website to download the latest version of the tool.

Basic usage of the pem command is very easy – you just have to pass an expense note or description, followed by the expense amount. Here is an example:

pem "Weekend Lunch" 700

pem-weekend-lunch

The command above stores the description “Weekend Lunch” as well as the amount 700 in a file, which is named after the current month, and placed in the “.pem” folder under your HOME directory.

Note: if the expense description consists only of a single word, it is not mandatory to put it in double quotes, but if there are multiple words, it should always be put in double quotes.

Here is what the file contains:

pem-cat-weekend-lunch

The format of the output is [code],[tag],[income],[expense]

Instead of using the standard file name and location (as specified in the previous example), you can also specify some other file using the -f option. Here is an example:

pem -f ~/Desktop/exp.txt "Birthday" 1000

pem-birthday

The command above will store the expense amount as well as details in the exp.txt file located on the Desktop.

Like any other expense manager, the pem tool also lets you record your earnings, which can be done using the -e option. Here is an example:

pem -e "Salary" 4000

pem-salary

You can attach tags or categories to your expenses or earnings using the -c option. For example:

pem -c 'travel fun' "Trip to Vegas" 4500

pem-travel-fun

The command shown in the screenshot above lists “Trip to Vegas” under the ‘travel fun’ category.

You can ask the pem command to display a daily report using the -s option. Here is an example:

pem -s

pem-display-table

You can also pass a number along with the above command to see a daily report with total after that many days. For example, pem -s 3 would display a daily report with a total after 3 days.

Similarly, you can use the -m option to display a monthly report.

Sometimes it is required to view results based on a particular category or tag. You can do just that using the pem command’s -C option. Here is an example:

pem -C travel

pem-display-tag

So you can see that the command shown in the screenshot above displays results related to the ‘travel’ category.

For more options, go through the man page.

The pem command may not offer advanced functionality, but it does provide features that a basic expense manager should. The real power of the tool, however, lies in the fact that it makes managing expenses from the command line very easy.

Have you ever used pem or any other command line-based expense manager? Share your experience in the comments below.