linux笔记_day05

1.bash以及特性

    shell:外壳

      GUI:KDE,Gnome,Xfce

      CLI:sh,csh,ksh,bash(born again shell)

    进程:在每个进程看来,当前主机上只存在内核和当前进程

        进程是程序的副本,是程序执行的实例

    pstree

      display a tree of processes

  shell 子shell

特性:

  1.命令历史

    history

      

  -c	clear the history list by deleting all of the entries
   -d   offset	(偏移)delete the history entry at offset OFFSET.
      root@good eric tmp]# history -d 100 10

   

  用户退出的时候会把命令保存在这个文件,

  也可以手动保存

    history -w:保存命令历史至历史文件

  

[root@good eric ~]# echo $HISTSIZE
            echo $变量名 查看变量的内容

  技巧:  !n 执行命令历史中的第n条命令

      !!执行上一条命令

      !man (字符串)命令历史中,以指定字符串开头的命令

      应用前一个命令最后一个参数

            !$

             Esc .

            alt+.

  2.管道符,重定向

  3.别名

    alias COMMAND=COMMAND

    在shell中定义的别名仅在当前shell进程

    撤销 unalias COMMAND

    

[root@good eric ~]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'

     别名永远生效 

[root@good eric ~]# vi .bashrc

    
	alias rm='rm -i'
	alias cp='cp -i'
	alias mv='mv -i'
	alias vnet='cd /opt'
	# Source global definitions
	if [ -f /etc/bashrc ]; then
			. /etc/bashrc
	fi
	~                          
~                              
[root@good eric ~]# source .bashrc 
[root@good eric ~]# vnet
[root@good eric opt]# 

 

  4.命令行编辑

    光标跳转:

      ctrl +a行首

      Ctrl+e行尾

      Ctrl+u删除光标至命令行首的内容

      Ctrl+k删除光标至命令行尾的内容

      ctrl+←一个单词

      ctrl+→一个单词

      ctrl +L 清屏幕            

  5.命令行展开

    

  6.文件名统配

    *  ?    []   [^]

    

 

  7.变量

  8.编程

  9.命令替换

  把命令中某个子命令替换为其执行结果  

  $()

  反引号``  

[root@good eric ~]# touch ./file_$(date +%F).txt
[root@good eric ~]# ls
anaconda-ks.cfg  file  file_  file1  file_2017-05-12.txt  file_.txt  install.log  install.log.syslog
[root@good eric ~]# 

 

 bash 支持的引号

    `` :命令替换

        "" :弱引用,可以实现变量替换

    ' ' :强引用

 

posted @ 2017-05-12 15:58  酸奶加绿茶  阅读(213)  评论(0编辑  收藏  举报