You're viewing a comment by djj and its responses.

djj Permalink
January 25, 2013, 01:01

I thought I'd replace sed/awk with bash using associative arrays and the redirection in your earlier one-liner. My history is prefixed with the date, time, as well as the number, thus the 3 _'s.

declare -A aA; while read -r _ _ _ cmd; do ((aA["${cmd}"]++)); done < <(history)

for cmd in "${!aA[@]}"; do if (( ${aA[$cmd]} > 1 )); then printf -- '%3d %-.50s\n' ${aA[$cmd]} "${cmd}"; fi; done | sort -rn

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "apple_334": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.