Linux Learning Notes (23) Shell Introduction, History command histories, command completion and aliases, wildcard characters,

Source: Internet
Author: User
Tags aliases

First, Shell introduction

    The
    1. Shell is a command interpreter that provides interaction between the user and the machine
    2. supports specific syntax, such as logical judgment, looping
    3. each user can have their own specific shell
    4. CentOS7 default shell is bash (Bourne Agin shell)
    5. also zsh, Ksh,
      II, History
    6. History command The

      is the most recently entered command history, and the command history is written to the current file in memory, and only once each time you exit the terminal normally, the command histories
    7. . bash_history
      Command history files
        echo $HISTSIZE  


      Command History Max 1000
      This setting can be modified in
      /etc/profile

        vim Etc/profile  


      If you want the history table to display a history command in the following command
      histtimeformat= "%y/%m/%d%h:%m:%s"
      only takes effect in the current command window when you execute it separately


      If you want to make it permanent, add the command to the/ETC/PROFILE environment variable

        Vim/etc/profilesource!$//Make environment variable effective  



      If you want the history file to be saved permanently

        chattr +a ~/.bash_history  

      This time the file can only be appended cannot be deleted, ignoring 1000 restrictions

       !!  

      To execute the previous command

       !n  

      To execute the nth command in the history command

       !word  

      Executes the last Word command in command history, where word can be replaced with any command

Iii. command Completion and aliases

tab, knock, Knock, double click.
A knock will automatically fill the command. If you have more than one command at the beginning, you'll need to double-tap to select from the list
Parameter completion, installation Bash-completion

 yum install -y bash-completion

Reboot required after installation

Alias aliases give the command a name again
Alias restartnet= ' systemctl restart Network.service '

Each user has their own configuration alias file ~/.BASHRC
This file has a few default alias
Some other aliases are stored under the/etc/profile.d/directory
ls/etc/profile.d/

Custom alias put to ~/.BASHRC
Canceling aliases with Unalias
四、通配符

ls *.txt  //列出所有的txt文件 ls ?.txt //列出文件名是一个字符的txt文件 ls [0-9].txt  //列出文件名是1-9的txt文件 ls [13].txt  //列出文件名是1或者3的txt文件 ls {1,2}.txt  //列出文件名为1的txt文件和文件名为2.txt文件,如果有其中一个不存在,会提示



V. Input/Output redirection

cat 1.txt >2.txt  //将前面命令的输出输入到后面的文件中(覆盖2.txt内容) cat 1.txt >> 2.txt  //将前面命令的输出追加输入到后面的文件中(在2.txt中追加) ls aaa.txt 2>err    //将前面命令的错误信息输入到后面的文件(覆盖) ls aaa.txt 2>>err   //将前面命令的错误信息追加输入到后面的文件(不覆盖) ls {1,6}.txt &>999.txt  //将正确和错误信息都输入到后面文件中 ls {1,6}.txt >999.txt 2>66.txt //将正确信息输入999.txt,错误信息输入66.txt wc -l < 1.txt   //输出右边文件的文件行数(左边需要是命令,不可以是文件)

Linux Learning Notes (23) Shell Introduction, History command histories, command completion and aliases, wildcard characters,

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.