10月11日任务shell
8.1 shell介绍vim
8.2 命令历史centos
8.3 命令补全和别名bash
8.4 通配符spa
8.5 输入输出重定向ip
8.1 shell介绍内存
什么是shell文档
8.2 命令历史io
#查看历史命令zsh
[root@centos6 ~]# history
#历史命令变量
[root@centos6 ~]# echo $HISTSIZE 1000
#history -c清空内存中的命令历史,但不能修改配置文件 .bash_history里的内容
[root@centos6 ~]# history -c [root@centos6 ~]# history 1 history [root@centos6 ~]# ls -l .bash_history -rw-------. 1 root root 1043 Oct 10 17:43 .bash_history
#编辑配置文件/etc/profile中HISTSIZE值修改成5000保存退出,想当即生效须要运行source /etc/profile 。
[root@centos6 ~]# vim /etc/profile [root@centos6 ~]# echo $HISTSIZE 1000 [root@centos6 ~]# source /etc/profile [root@centos6 ~]# echo $HISTSIZE 5000
#编辑配置文件/etc/profile,在文档中HISTSIZE值下边一行添加HISTTIMEFORMAT="%Y/%m/%d% H:%M:%S",表示以年月日时间格式显示命令历史。
[root@centos6 ~]# vim /etc/profile
HISTSIZE=5000 HISTTIMEFORMAT="%Y/%m/%d% H:%M:%S"
[root@centos6 ~]# history
1 2018/10/11 10:04:15vi /etc/sysconfig/network-scripts/ifcfg-eth0
#给历史命令文件添加隐藏权限a,表示只能追加内容,不能删除。这样就能够永久保存历史记录。
[root@centos6 ~]# chattr +a ~/.bash_history [root@centos6 ~]# lsattr .bash_history -----a-------e- .bash_history
8.3 命令补全和别名
8.4 通配符
#范例 :&>表示把错误和正确的结果都输出到a文件 , 同理&>>表示追加。
[root@centos6 ~]# touch 1.txt [root@centos6 ~]# ls 1.txt anaconda-ks.cfg install.log install.log.syslog [root@centos6 ~]# ls 1.txt aaa.txt &> a.txt [root@centos6 ~]# cat a.txt ls: cannot access aaa.txt: No such file or directory 1.txt
#把正确和错误的输出结果分别保存到不一样文件。
[root@centos6 ~]# ls 1.txt aaa.txt > a.txt 2>b.txt [root@centos6 ~]# cat a.txt 1.txt [root@centos6 ~]# cat b.txt ls: cannot access aaa.txt: No such file or directory