Which Linux terminal command do you use the most?

Chat about Linux in general
Forum rules
Do not post support questions here. Before you post read the forum rules. Topics in this forum are automatically closed 6 months after creation.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Which Linux terminal command do you use the most?

Post by rene »

BG405 wrote: Fri Sep 07, 2018 9:11 pm I'd be interested to find out how to filter out the display of the history result, which is affected by executing this, would help me to understand how this works .. will have to explore all this. I'm intrigued now. :)
Although I'm inclined to myself feel that being intrigued by 'awk' in 2018 might not necessarily lead to the best use of one's time... if you in the second version I posted, the one that filters commands starting with "./", replace the "$2!~/^.\//" [edit: which actually should escape the . as well] with "$2!~/^history/" that would work. Or filter both with "$2!~/^(\.\/|history)/". Just keep adding "|foo|bar" inside the parentheses to filter additional commands.

Code: Select all

history | awk '$2!~/^(\.\/|history)/ { if ($2 != "sudo" || $3 == "-s" || $3 == "-i") cmd[$2]++; else cmd[$3]++; n++; } END { for (s in cmd) { printf("%d %d%% %s ",cmd[s],cmd[s]*100/n,s); for (i=0;i<cmd[s]/12;i++) printf("▄"); printf("\n") } }' | sort -nr | head -n10 | column -t | nl
The fun of 'awk' is as far as I'm concerned mostly the arcania -- although it does in fact sometimes still come in handy.
Last edited by rene on Sat Sep 08, 2018 12:50 pm, edited 3 times in total.
User avatar
AndyMH
Level 21
Level 21
Posts: 13728
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Which Linux terminal command do you use the most?

Post by AndyMH »

I am in awe of those that understand awk, and wow, now many pipes in that:

Code: Select all

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
sudo came top of my list followed by man and inxi.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
Pepi
Level 6
Level 6
Posts: 1305
Joined: Wed Nov 18, 2009 7:47 pm

Re: Which Linux terminal command do you use the most?

Post by Pepi »

help :mrgreen:
User avatar
kc1di
Level 18
Level 18
Posts: 8175
Joined: Mon Sep 08, 2008 8:44 pm
Location: Maine USA

Re: Which Linux terminal command do you use the most?

Post by kc1di »

short list, But then this is only a 1 day old install :)

Code: Select all

s 1	12  52.1739%  sudo
     2	4   17.3913%  cd
     3	3   13.0435%  ls
     4	1   4.34783%  wine
     5	1   4.34783%  sh
     6	1   4.34783%  history
     7	1   4.34783%  find
Easy tips : https://easylinuxtipsproject.blogspot.com/ Pjotr's Great Linux projects page.
Linux Mint Installation Guide: http://linuxmint-installation-guide.rea ... en/latest/
Registered Linux User #462608
User avatar
kc1di
Level 18
Level 18
Posts: 8175
Joined: Mon Sep 08, 2008 8:44 pm
Location: Maine USA

Re: Which Linux terminal command do you use the most?

Post by kc1di »

short list, But then this is only a 1 day old install :)

Code: Select all

s 1	12  52.1739%  sudo
     2	4   17.3913%  cd
     3	3   13.0435%  ls
     4	1   4.34783%  wine
     5	1   4.34783%  sh
     6	1   4.34783%  history
     7	1   4.34783%  find
Easy tips : https://easylinuxtipsproject.blogspot.com/ Pjotr's Great Linux projects page.
Linux Mint Installation Guide: http://linuxmint-installation-guide.rea ... en/latest/
Registered Linux User #462608
Locked

Return to “Chat about Linux”