David Haller wrote:
==== #!/bin/bash HFILE="$1" TMPF="$(mktemp "${HFILE}.$$.XXXXXXXXXX")" if time tac "$HFILE" | awk '!x[$0]++ { print; }' > "${TMPF}"; then tac "${TMPF}" > "${HFILE}" && rm "${TMPF}" fi ====
I'm not 100% sure, but the above looks like it might not filter out your dups as it doesn't sort them. I.e. if you run unsorted input into 'uniq', you won't get 'uniq' output. Also not sure why the time command is there? Are you trying to time the tac command? I ran your script on a concatenation of my 'tty-hist files' and first few lines of output from your script were: First several lines of your output: #1382638179 ps -ef|grep fetch #1382791092 #1382791960 #1382792415 #1382793525 -------------- Feeding same input into my script showed top entries: #1328153686 ls repo-oss #1328153702 ls repo-oss/suse/x86_64/ #1328153720 rpm -qpi repo-oss/suse/x86_64/xfce4-panel-plugin-xkb-0.5.3.3-7.1.x86_64.rpm #1328153783 rm -fr repo-{update,oss,source} #1328153788 --- Two observations: 1) why would your script keep 'uniq' blank lines? I.e. the consecutive timestamps w/no command & 2, the output from your script shows its 1st command starting 60 million seconds later than my script (which I think is related to it not being sorted). Besides blank lines, I try to filter out bogus or trival commands, and unlike bash -- if my script finds a dup -- it updates the 'seconds' field for that command so the time field shows the last time I used that command. That way my more frequently used commands end up near the end of the list... Your script is *way* shorter than mine though: (not including library calls! *sigh*)...
wc bin/hist_dedup 137 487 3707 bin/hist_dedup
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org