web analytics

Unix: print in color

This simple procedure takes 3 arguments as the parameters:

Text Foreground color Background color

It prints the text to the terminal in selected colors.

function print_color {  local text=$1  local fg=$2  local bg=$3  case "$fg" in  red) fg="31m" ;;  green) fg="32m" ;;  yellow) fg="33m" ;;  blue) fg="34m" ;;  white) fg="37m" ;;  black) fg="30m" ;;  *) […]

Unix: rename files to lowercase

It’s very simple to rename the files to lowercase/uppercase using awk:


ls -1rt | awk ‘{ printf("mv %s %s\n", $0, tolower($0)) | "sh" } END { close("sh") }’


ls -1rt | awk ‘{ printf("mv %s %s\n", $0, toupper($0)) | "sh" } END { close("sh") }’

Unix: how to get md5 sum

Here are the possibilities to calculate md5 sum:

(Linux): md5sum filename

(Solaris): digest -a md5 -v filename

Oracle: quotes and quote operator

There are several methods to put the quote into the string.

The first (and very traditional) one: use 2 quotes.

SELECT ‘This ” is quote’ FROM dual;

If there are more than one quote, it’s difficult to read and write such strings

The second: use chr(39)

SELECT ‘This ‘ || CHR(39) || ‘ is quote’ […]