Thursday, December 25, 2014

[Ruby] string to hex, hex to string

String to Hex

require 'digest'
Hex to String


Wednesday, December 3, 2014

Calculate sum of memory usage data with Awk

I don't know how to use awk, but I have a problem which I know it suits for.

I want to sum up memory usage data that come out from executing the command ps aux. I learned 2 usages of awk from this lesson.

Print value of a column with:
awk '{ print $COLUMN_NUMBER }'

Sum value of a column with:
awk '{ temp = temp + $COLUMN_NUMBER }END{ print temp }'

So I can get sum of memory usage of processes with certain name pattern like this:
$ ps aux | grep NAME_PATTERN | awk '{temp = temp + $6}END{ print temp }'

I still don't know awk, but at least I'm incrementally learning it.

simple awk tutorial
Add up a column of numbers at the Unix shell

Config number of file descriptors on Linux

Check file descriptor limit for a process. Vary depending on owner of the process $ cat /proc/{process-id}/limits Check current number of...