<!-- 
.. title: Miscellanea
.. slug: miscellanea
.. date: 2012-04-29 19:06:44 UTC+01:00 
.. tags: linux, 
.. link: 
.. description: 
.. type: text 
--> 

To calculate the average or the maximum of the second column of data files, do

	awk '{sum += $2} END {printf ("%f\n", sum/NR)}' $1

or

	awk 'BEGIN {max = 0} {if ($2>max) max=$2} END {print max}' $1

The latter one is particularly useful for a quick-and-dirty plot of normalized spectra with gnuplot.

----

The easiest way to get the geometry of an image is

	identify -format "%wx%h\n" *

----

To enable applications requiring X to be started with root rights without having access to kdesu or gksu, steal the magic cookie from your users 😄

	xauth add `xauth -f ~user/.Xauthority list $DISPLAY`

