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}'
Dec 15th
1 tag
All about dd →
Dec 15th
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)
Dec 7th
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
Dec 3rd
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!
Dec 3rd