December 2009
5 posts
1 tag
Passing Variables to awk in a script
To pass bash variables to an awk script, use -v to turn them into awk variables first:
awk -v var=$var '{print $1 + var}'
1 tag
All about dd →
3 tags
Profiling C Code with Gprof
Use Gnu Prof to find out how much CPU time is spent in each function and how often they are called.
First, compile the code with the -pg flag
Then, run the program as usual. It will produce a gmon.out file
Run gprof execname to view the output statistics (probably want to redirect or use less)
1 tag
Averaging all columns with AWK
From here
Very handy for processing data files:
awk '{for(i=1; i<=NF; i++){sum[i]+=$i}} END {for(i=1; i<=NF; i++){printf sum[i]/NR "\t"}}' file
1 tag
Growl message popups
To make a “growl” message appear, first install the growlnotify app from the extras folder in the growl distribution. Then you can run:
ssh soporifix.cs.umass.edu “echo test message | /usr/local/bin/growlnotify -s”
to make a sticky growl notification appear. Nice for alerts that an experiment is done!