Fun with history - Off topic

Users browsing this thread: 1 Guest(s)
pranomostro
Long time nixers
Hi y'all,
yesterday I played around with the history function
in different shells.

First, I wanted to know how many unique shell commands I had used during
the last month:
Code:
» history | wc -l
6840

This works because my main shell (fish) does not show duplicate shell commands.
Interesting. I thought this would be more, provided that I am nearly exclusively using
the shell.

Next I wanted to take a look at the longest command lines I ever wrote:

Code:
» history | awk '{ print length() " " $0 }' | sort -n | sed 's/^[0-9]\+ //' | tail -5

Code:
mv "Beißkraft\ -\ Bisskraft\ -\ Report\ -\ Beißkraft\ Übersicht\ -\ Bisskraft\ Übersicht\ -\ Beißkraft\ Vergleich\ -\ Extremes\ und\ Rekorde\ aus\ aller\ Welt" beißkraftvergleich
mv Beißkraft\ -\ Bisskraft\ -\ Report\ -\ Beißkraft\ Übersicht\ -\ Bisskraft\ Übersicht\ -\ Beißkraft\ Vergleich\ -\ Extremes\ und\ Rekorde\ aus\ aller\ Welt.html beißkraftvergleich.html
for i in (l); cd $i; for i in (l); set j (echo $i | tr A-Z a-z | tr ' -' '_' | tr -d "'()#&!?,*\$|~`+%[]^<>=/{}:@" | sed 's/__\+/_/g' | sed 's/^[0-9][0-9]_//'); echo $j; end; cd ..; end | p
for i in (l); cd $i; for i in (l); set j (echo $i | tr A-Z a-z | tr ' -' '_' | tr -d "'()#&!?.*\$|~`+%[]^<>=/{}:@" | sed 's/__\+/_/g' | sed 's/^[0-9][0-9]_//'); echo $j; end; cd ..; end | p
for i in (l); cd $i; for i in (l); set j (echo $i | tr A-Z a-z | tr ' -' '_' | tr -d "'()#&!?,*\$|~`+%[]^<>=/{}:@" | sed 's/__\+/_/g' | sed 's/^[0-9][0-9]_//'); mv "$i" $j; end; cd ..; end | p
These are my top five.

Also, I looked what my most used commands were:
Code:
» history | tr '|' '\n' | sort | field 1 | uniq -c | awk '$2~/^[a-z]+$/' | sort -n | tail -20

The result was interesting:
Code:
109 sudo
    124 ag
    125 git
    127 cat
    133 less
    141 play
    143 man
    153 tr
    154 sts
    163 sed
    174 uniq
    179 r
    195 cd
    199 awk
    214 mv
    229 cd
    243 field
    326 sort
    354 cd
    463 cat

'play' is a wrapper script for ogg123, 'sts' is a command to start the sam text editor in the background,
'r' is a script that moves files to ~/trash, and 'field NUM' prints the NUMth field in the input, for
every line. Everything else is standard, I suppose.

It seems like I mostly use the shell for printing stuff, going somewhere and sorting things.
Maybe I should make an alias for cat, like 'c' or something...

A slightly changed version shows the frequency of commands at the beginning of command lines:
Code:
» history | field 1 | sort | uniq -c | sort -n | tail -20

Here, the result is quite different:
Code:
71 md
     72 du
     72 mupdf
     86 cp
     87 pn
     92 less
     98 history
    101 pipes
    107 for
    109 sudo
    123 ag
    141 play
    169 l
    214 mv
    220 sts
    227 man
    426 git
    433 r
    696 cat
    792 cd

I still seem to use cd and cat a lot, but it also looks like I enjoyed pipes (for some period).
'pn' is an alias for the potion interpreter, to make it easier to type, and 'md' is an alias for mkdir.

So, that's all I've got so far. If you want to share parts of your history, feel free to do so.
venam
Administrators
That's an interesting analyze of history.
You could extract the most used commands an make a boostrap script to set them up on your new installs.
That way you won't get lost.
ninjacharlie
Members
(27-10-2015, 03:04 PM)venam Wrote: That's an interesting analyze of history.
You could extract the most used commands an make a boostrap script to set them up on your new installs.
That way you won't get lost.
Whoa! Awesome idea! Only problem is a lot of the commands I use are built from source (cloned from GitHub), but still would be useful for remembering what I forgot to install :P