Of Linux, Programming, and Singaporean Ramblings

Converting Certificates

Tue, Jan 13, 2015

Here’s the command this article is talking about:

openssl x509 -in proxy.cer -inform der -outform pem -out proxy.crt

This command basically converts a binary certificate into a base64-encoded one (i.e. text).

Read more

Stripping Carriage Returns From Text Files

Tue, Aug 19, 2014

One of the problems with working on Linux and Windows OSes has to do with manipulating text files. Lines are separated by a carriage return and a line break character in text files on Windows, whereas on Linux, they separation is done through a single line break character.

When text files from Windows are opened in Linux, you often see ^M appearing at the end of lines like this:

Line 1^M
Line 2^M

The easiest way to remove the carriage return characters (represented by ^M) is to use the dos2unix command. This lightweight program can be easily obtained on Debian-based systems with the command:

sudo apt-get install dos2unix

Other than using the dos2unix command, the fastest way to remove the carriage return characters is the following command:

cat file1.txt | tr -d '\r' > file2.txt

Resizing Multiple Images in Linux

Sun, Nov 29, 2009

During the lifetime of using the computer, I believe everyone will inevitably face the scenario where you will want resize multiple images to a certain size.

In Linux, you can do it will such ease that makes you wonder what you use Windows for.

This effect can be easily done using the command line. Naysayers will probably disclaim the effectiveness of this tip but it really is easy for those who know Linux. All you have to do is to go into the directory where the images are stored and run the following command:

for k in $(ls *.jpg); do convert $k -resize 1024x768 -quality 100 re_$k; done
Read more
Tags: linux bash
Page 1 of 1