Skip to content

Instantly share code, notes, and snippets.

@mrflip
Created April 8, 2011 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrflip/910255 to your computer and use it in GitHub Desktop.
Save mrflip/910255 to your computer and use it in GitHub Desktop.
Your commandline is a perfectly good ruby IDE.
# ugh, have to learn awk
cat /tmp/foo.txt | awk '{print $2 " " $11}' | sort | uniq
# more prolix, but scales to complex scripts
cat /tmp/foo.txt | ruby -ne 'puts $_.split.values_at(1,10).join("\t")' | sort | uniq
cat /tmp/foo.txt | ruby -e 'bins = Hash.new{|h,k| h[k] = []} ; $stdin.readlines.map(&:split).each{|r| bins[r[1]] << r[10] } ; bins.each{|band,obs| puts [band, obs.count,obs.join(",")].join("\t") }'
QSO: 14000 CW 2011-03-19 1229 W1JQ 599 0001 UV5U 599 0041
QSO: 14000 CW 2011-03-19 1232 W1JQ 599 0002 SO2O 599 0043
QSO: 21000 CW 2011-03-19 1235 W1JQ 599 0003 RG3K 599 VR
QSO: 21000 CW 2011-03-19 1235 W1JQ 599 0004 UD3D 599 MO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment