https://wangdoc.com/bash/grammar.html#echo-%E5%91%BD%E4%BB%A4

    1. [root@dev-yum-server ~]# cat /etc/shells
    2. /bin/sh
    3. /bin/bash
    4. /sbin/nologin
    5. /usr/bin/sh
    6. /usr/bin/bash
    7. /usr/sbin/nologin
    8. /bin/tcsh
    9. /bin/csh
    10. [root@dev-yum-server ~]# echo $SHELL
    11. /bin/bash
    12. [root@dev-yum-server ~]#

    查看bash版本

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

    echo

    1. [root@dev-yum-server ~]# echo hello world
    2. hello world
    3. [root@dev-yum-server ~]# echo -n hello world
    4. hello world[root@dev-yum-server ~]#
    5. [root@dev-yum-server ~]#
    6. [root@dev-yum-server ~]# echo -n a;echo b
    7. ab
    8. [root@dev-yum-server ~]#

    echo -n

    1. [root@dev-yum-server ~]# echo -n a;echo b
    2. ab
    3. [root@dev-yum-server ~]#

    echo -e

    1. [root@dev-yum-server ~]# echo "Hello\nWorld"
    2. Hello\nWorld
    3. [root@dev-yum-server ~]#
    4. [root@dev-yum-server ~]# echo -e "Hello\nWorld"
    5. Hello
    6. World
    7. [root@dev-yum-server ~]# echo -e 'Hello\nWorld'
    8. Hello
    9. World
    10. [root@dev-yum-server ~]#

    分号;

    1. [root@dev-yum-server ~]# clear; ls
    2. anaconda-ks.cfg
    3. done
    4. echo
    5. initial-setup-ks.cfg
    6. Install_CSSPC5.0_Linux_64bit_v1.9.47.20200514.tar
    7. Install_CSSPM5.0_Linux_mysql_64bit_v1.8.116.20200512.tar
    8. source
    9. time
    10. vmtools
    11. vmtools-2.5.0.156.tar.bz2
    12. [root@dev-yum-server ~]#
    1. [root@dev-yum-server ~]# w;df -TH
    2. 13:28:02 up 9 days, 12:48, 3 users, load average: 0.00, 0.01, 0.05
    3. USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
    4. chroot pts/1 22.188.80.9 11:07 2.00s 0.17s 0.02s sshd: chroot [priv]
    5. chroot pts/2 22.188.80.168 11:44 9:46 0.04s 0.01s ssh root@10.82.100.88
    6. chroot pts/3 22.188.80.168 12:21 11:14 0.09s 0.08s ssh root@10.82.100.87
    7. Filesystem Type Size Used Avail Use% Mounted on
    8. /dev/mapper/rootvg-root ext4 11G 5.0G 4.9G 51% /
    9. devtmpfs devtmpfs 4.1G 0 4.1G 0% /dev
    10. tmpfs tmpfs 4.2G 0 4.2G 0% /dev/shm
    11. tmpfs tmpfs 4.2G 27M 4.1G 1% /run
    12. tmpfs tmpfs 4.2G 0 4.2G 0% /sys/fs/cgroup
    13. /dev/mapper/rootvg-usr ext4 11G 3.6G 6.3G 37% /usr
    14. /dev/vda1 xfs 534M 213M 321M 40% /boot
    15. /dev/vda2 vfat 1.1G 13k 1.1G 1% /boot/efi
    16. /dev/mapper/rootvg-var ext4 11G 780M 9.2G 8% /var
    17. /dev/mapper/rootvg-home ext4 11G 43M 9.9G 1% /home
    18. /dev/mapper/rootvg-tmp ext4 11G 280M 9.7G 3% /tmp
    19. /dev/mapper/rootvg-opt ext4 11G 125M 9.8G 2% /opt
    20. /dev/mapper/rootvg-app ext4 11G 38M 9.9G 1% /app
    21. /dev/loop0 iso9660 4.1G 4.1G 0 100% /yum/rehl7.4
    22. tmpfs tmpfs 821M 13k 821M 1% /run/user/42
    23. tmpfs tmpfs 821M 0 821M 0% /run/user/1000
    24. [root@dev-yum-server ~]#

    && 成功后才执行后面
    || 成功后就不执行后面的

    1. [root@dev-yum-server ~]# ls -l && w
    2. total 673888
    3. -rw-------. 1 root root 2401 May 7 16:57 anaconda-ks.cfg
    4. -rw-r--r-- 1 root root 0 Jun 26 11:20 done
    5. -rw-r--r-- 1 root root 0 Jun 26 11:20 echo
    6. -rw-r--r--. 1 root root 2449 May 7 16:59 initial-setup-ks.cfg
    7. -rw-r--r-- 1 root root 151848960 May 18 10:22 Install_CSSPC5.0_Linux_64bit_v1.9.47.20200514.tar
    8. -rw-r--r-- 1 root root 519802880 May 18 10:21 Install_CSSPM5.0_Linux_mysql_64bit_v1.8.116.20200512.tar
    9. drwxr-xr-x 3 root root 4096 May 28 13:19 source
    10. -rw-r--r-- 1 root root 0 Jun 26 11:20 time
    11. drwxr-xr-x. 6 root root 4096 Aug 1 2019 vmtools
    12. -r--r--r--. 1 root root 18380837 May 7 17:09 vmtools-2.5.0.156.tar.bz2
    13. 13:31:03 up 9 days, 12:51, 3 users, load average: 0.00, 0.01, 0.05
    14. USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
    15. chroot pts/1 22.188.80.9 11:07 7.00s 0.18s 0.02s sshd: chroot [priv]
    16. chroot pts/2 22.188.80.168 11:44 23.00s 0.04s 0.01s ssh root@10.82.100.88
    17. chroot pts/3 22.188.80.168 12:21 14:15 0.09s 0.08s ssh root@10.82.100.87
    18. [root@dev-yum-server ~]# ls -l || w
    19. total 673888
    20. -rw-------. 1 root root 2401 May 7 16:57 anaconda-ks.cfg
    21. -rw-r--r-- 1 root root 0 Jun 26 11:20 done
    22. -rw-r--r-- 1 root root 0 Jun 26 11:20 echo
    23. -rw-r--r--. 1 root root 2449 May 7 16:59 initial-setup-ks.cfg
    24. -rw-r--r-- 1 root root 151848960 May 18 10:22 Install_CSSPC5.0_Linux_64bit_v1.9.47.20200514.tar
    25. -rw-r--r-- 1 root root 519802880 May 18 10:21 Install_CSSPM5.0_Linux_mysql_64bit_v1.8.116.20200512.tar
    26. drwxr-xr-x 3 root root 4096 May 28 13:19 source
    27. -rw-r--r-- 1 root root 0 Jun 26 11:20 time
    28. drwxr-xr-x. 6 root root 4096 Aug 1 2019 vmtools
    29. -r--r--r--. 1 root root 18380837 May 7 17:09 vmtools-2.5.0.156.tar.bz2
    30. [root@dev-yum-server ~]#

    type 判断命令来源

    1. [root@dev-yum-server ~]# type echo
    2. echo is a shell builtin
    3. [root@dev-yum-server ~]# type w
    4. w is hashed (/bin/w)
    5. [root@dev-yum-server ~]#

    快捷方式

    1. Ctrl + U:从光标位置删除到行首
    2. Ctrl + K:从光标位置删除到行尾