Requirements: List which commands are most used and enter them into Chy1.txt
Idea: Our command is all there is a history file/root/.bash_history This file, you need to sort the commands used here.
[[email protected] shell]# vim history.sh #!/bin/bash#this is liechu History zuiduodminglingsort /root/.bash_history |uniq -c |sort -nr |head >/tmp/chy1.txt (script command explanation:uniq -c shows the number of repetitions, sort -nr the number in the form of a number in front of the small row in the back) [[email protected] shell]# sh history.sh (execute this script) [[Email protected] shell]# cat /tmp/chy1.txt 49 ls 47 /usr/ local/apache2.4/bin/apachectl graceful 39 vim /usr/local/apache2.4 /conf/extra/httpd-vhosts.conf 32 ip addr 28 init 0 25 vim /etc/keepalived/keepalived.conf 19 ps aux |grep nginx 19 git push 19 cd chenhaiying/ 17 mysql - Uroot (and view the historical content entered into the Chy1.txt) hope to see the children's shoes a lot of advice, thank you!
Shell Exercise 01: List the commands that use the most and enter them into Chy1.txt