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