Shell Introduction Command history command completion and alias wildcard input and output redirection

Source: Internet
Author: User

8.1 Shell Introduction

The shell is a command interpreter that provides interaction between the user and the machine to support specific syntax, such as logical judgment, looping each user can have their own specific shell CentOS7 default shell for bash (Bourne Agin shell) and zsh, Ksh and other Yum Zsh and Ksh

[[email protected] ~]# yum list |grep zsh zsh.x86_64                                 5.0.2-25.el7_3.1            updates   zsh-html.x86_64                            5.0.2-25.el7_3.1            updates  [[email protected] ~]# yum list |grep kshksh.x86_64                                 20120801-26.el7             base     mksh.x86_64
8.2 Command History

History command
Bash_history
Maximum 1000 articles
Variable histsize
Modify in/etc/profile
histtimeformat= "%y/%m/%d%h:%m:%s"
Permanently save Chattr+a~/.bash_history
!!
!n
!word

敲过的命令保存在用户的家目录下 [[email protected] httpd-2.2.34]# ls /root/.bash_history/root/.bash_history显示所有的敲过的命令[[email protected] ~]# cat /root/.bash_history如果需要统计多少数量,可以输入[[email protected] ~]# history可以保存1000条[[email protected] ~]# echo $HISTSIZE1000清空历史命令[[email protected] ~]# history -c变量HISTSIZE可以通过以下命令修改参数[[email protected] ~]# vi /etc/profile修改HISTSIZE=5000退出[[email protected] ~]# echo $HISTSIZE1000[[email protected] ~]# source /etc/profile                   //需要输入此命令保  存生效// -bash: ii: 未找到命令 -bash: /: 是一个目录 [[email protected] ~]# echo $HISTSIZE5000如何记录下历史命令是什么时候运行的在编辑模式下[[email protected] ~]# vim /etc/profileHISTSIZE=5000               在此条命令下一行插入以下命令HISTTIMEFORMAT="%Y/%m/%d%H:%M:%S"退出[[email protected] ~]# source !$source /etc/profile!!最后一条命令!n表示想运行第几行的命令!echo  从下往上找以echo为首的命令的一行
8.3 Command Completion and aliases

tab, tap, double-click parameter completion, install bash-completion alias alias to command re-name each user has their own configuration alias file ~/.BASHRC ls/etc/profike.d/custom alias put to ~/.BASHRC

tab, tap to fill, and double-click to list possible parameters

Installing Bash-completion

 [[email protected] ~]# yum install -y bash-completion

Alias is an alias for viewing a command, or an alias for a sequence of commands

8.4-8.5 wildcard input and output redirection

LS *.txt//TXT file listing all prefixes//
Ls?. TXT//list all TXT files prefixed with only one digit//
ls [0-9].txt//List of selected files in parentheses//
Ls{1,2}.txt//The same as above, or meaning//
Cat 1.txt>2.txt//input the output of the preceding command into a later file//
Cat 1.txt>>2.txt//Append//
LS aaa.txt 2>err//Error re-set//
LS aaa.txt 2>>err//error append reset//
Wc-l <1.txt//Put a file or content on the right to the left of the re-entry, the left must be a command//
Command >1.txt 2>&1//correct and wrong input to right re-set

Shell Introduction Command history command completion and alias wildcard input and output redirection

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.