Fun with history - Printable Version +- nixers (https://nixers.net) +-- Forum: General (https://nixers.net/Forum-General) +--- Forum: Off topic (https://nixers.net/Forum-Off-topic) +--- Thread: Fun with history (/Thread-Fun-with-history) |
Fun with history - pranomostro - 27-10-2015 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 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 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 '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 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. RE: Fun with history - venam - 27-10-2015 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. RE: Fun with history - ninjacharlie - 27-10-2015 (27-10-2015, 03:04 PM)venam Wrote: That's an interesting analyze of history.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 |