Shell Exercise 01: List the commands that are most used and enter them into Chy1.txt

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.