查看当前系统使用的SHELL

    1. [root@localhost ~]# echo $SHELL
    2. /bin/bash

    查看当前系统所支持的所有SHELL

    [root@localhost ~]# cat /etc/shells
    /bin/sh
    /bin/bash
    /usr/bin/sh
    /usr/bin/bash
    

    查看bash的版本:方式一(bash -version) 方式二(echo $BASH_VERSION)

    [root@localhost ~]# bash -version
    GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
    Copyright (C) 2011 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    
    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    [root@localhost ~]# echo $BASH_VERSION
    4.2.46(2)-release
    [root@localhost ~]#
    

    echo -n 取消命令的换行符:
    image.png

    [root@localhost ~]# echo "a";  echo "b"
    a
    b
    

    使用echo -n 之后 命令如下:

    echo  -n "a";  echo "b"
    ab
    

    分号,用于分割两个不同的命令

     echo "a";echo "b"
    a
    b
    

    除了分号,Bash 还提供两个命令组合符&&||,允许更好地控制多个命令之间的继发关系。

    Command1 && Command2
    

    上面命令的意思是,如果Command1命令运行成功,则继续运行Command2命令。

    Command1 || Command2
    

    上面命令的意思是,如果Command1命令运行失败,则继续运行Command2命令。
    下面是一些例子。

    $ cat filelist.txt ; ls -l filelist.txt
    

    上面例子中,只要cat命令执行结束,不管成功或失败,都会继续执行ls命令。

    $ cat filelist.txt && ls -l filelist.txt
    

    上面例子中,只有cat命令执行成功,才会继续执行ls命令。如果cat执行失败(比如不存在文件flielist.txt),那么ls命令就不会执行。

    $ mkdir foo || mkdir bar
    

    上面例子中,只有mkdir foo命令执行失败(比如foo目录已经存在),才会继续执行mkdir bar命令。如果mkdir foo命令执行成功,就不会创建bar目录了。