https://wangdoc.com/bash/grammar.html#echo-%E5%91%BD%E4%BB%A4
[root@dev-yum-server ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh
[root@dev-yum-server ~]# echo $SHELL
/bin/bash
[root@dev-yum-server ~]#
查看bash版本
[root@dev-yum-server ~]# 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@dev-yum-server ~]#
[root@dev-yum-server ~]# echo $BASH_VERSION
4.2.46(2)-release
[root@dev-yum-server ~]#
echo
[root@dev-yum-server ~]# echo hello world
hello world
[root@dev-yum-server ~]# echo -n hello world
hello world[root@dev-yum-server ~]#
[root@dev-yum-server ~]#
[root@dev-yum-server ~]# echo -n a;echo b
ab
[root@dev-yum-server ~]#
echo -n
[root@dev-yum-server ~]# echo -n a;echo b
ab
[root@dev-yum-server ~]#
echo -e
[root@dev-yum-server ~]# echo "Hello\nWorld"
Hello\nWorld
[root@dev-yum-server ~]#
[root@dev-yum-server ~]# echo -e "Hello\nWorld"
Hello
World
[root@dev-yum-server ~]# echo -e 'Hello\nWorld'
Hello
World
[root@dev-yum-server ~]#
分号;
[root@dev-yum-server ~]# clear; ls
anaconda-ks.cfg
done
echo
initial-setup-ks.cfg
Install_CSSPC5.0_Linux_64bit_v1.9.47.20200514.tar
Install_CSSPM5.0_Linux_mysql_64bit_v1.8.116.20200512.tar
source
time
vmtools
vmtools-2.5.0.156.tar.bz2
[root@dev-yum-server ~]#
[root@dev-yum-server ~]# w;df -TH
13:28:02 up 9 days, 12:48, 3 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
chroot pts/1 22.188.80.9 11:07 2.00s 0.17s 0.02s sshd: chroot [priv]
chroot pts/2 22.188.80.168 11:44 9:46 0.04s 0.01s ssh root@10.82.100.88
chroot pts/3 22.188.80.168 12:21 11:14 0.09s 0.08s ssh root@10.82.100.87
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rootvg-root ext4 11G 5.0G 4.9G 51% /
devtmpfs devtmpfs 4.1G 0 4.1G 0% /dev
tmpfs tmpfs 4.2G 0 4.2G 0% /dev/shm
tmpfs tmpfs 4.2G 27M 4.1G 1% /run
tmpfs tmpfs 4.2G 0 4.2G 0% /sys/fs/cgroup
/dev/mapper/rootvg-usr ext4 11G 3.6G 6.3G 37% /usr
/dev/vda1 xfs 534M 213M 321M 40% /boot
/dev/vda2 vfat 1.1G 13k 1.1G 1% /boot/efi
/dev/mapper/rootvg-var ext4 11G 780M 9.2G 8% /var
/dev/mapper/rootvg-home ext4 11G 43M 9.9G 1% /home
/dev/mapper/rootvg-tmp ext4 11G 280M 9.7G 3% /tmp
/dev/mapper/rootvg-opt ext4 11G 125M 9.8G 2% /opt
/dev/mapper/rootvg-app ext4 11G 38M 9.9G 1% /app
/dev/loop0 iso9660 4.1G 4.1G 0 100% /yum/rehl7.4
tmpfs tmpfs 821M 13k 821M 1% /run/user/42
tmpfs tmpfs 821M 0 821M 0% /run/user/1000
[root@dev-yum-server ~]#
&& 成功后才执行后面
|| 成功后就不执行后面的
[root@dev-yum-server ~]# ls -l && w
total 673888
-rw-------. 1 root root 2401 May 7 16:57 anaconda-ks.cfg
-rw-r--r-- 1 root root 0 Jun 26 11:20 done
-rw-r--r-- 1 root root 0 Jun 26 11:20 echo
-rw-r--r--. 1 root root 2449 May 7 16:59 initial-setup-ks.cfg
-rw-r--r-- 1 root root 151848960 May 18 10:22 Install_CSSPC5.0_Linux_64bit_v1.9.47.20200514.tar
-rw-r--r-- 1 root root 519802880 May 18 10:21 Install_CSSPM5.0_Linux_mysql_64bit_v1.8.116.20200512.tar
drwxr-xr-x 3 root root 4096 May 28 13:19 source
-rw-r--r-- 1 root root 0 Jun 26 11:20 time
drwxr-xr-x. 6 root root 4096 Aug 1 2019 vmtools
-r--r--r--. 1 root root 18380837 May 7 17:09 vmtools-2.5.0.156.tar.bz2
13:31:03 up 9 days, 12:51, 3 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
chroot pts/1 22.188.80.9 11:07 7.00s 0.18s 0.02s sshd: chroot [priv]
chroot pts/2 22.188.80.168 11:44 23.00s 0.04s 0.01s ssh root@10.82.100.88
chroot pts/3 22.188.80.168 12:21 14:15 0.09s 0.08s ssh root@10.82.100.87
[root@dev-yum-server ~]# ls -l || w
total 673888
-rw-------. 1 root root 2401 May 7 16:57 anaconda-ks.cfg
-rw-r--r-- 1 root root 0 Jun 26 11:20 done
-rw-r--r-- 1 root root 0 Jun 26 11:20 echo
-rw-r--r--. 1 root root 2449 May 7 16:59 initial-setup-ks.cfg
-rw-r--r-- 1 root root 151848960 May 18 10:22 Install_CSSPC5.0_Linux_64bit_v1.9.47.20200514.tar
-rw-r--r-- 1 root root 519802880 May 18 10:21 Install_CSSPM5.0_Linux_mysql_64bit_v1.8.116.20200512.tar
drwxr-xr-x 3 root root 4096 May 28 13:19 source
-rw-r--r-- 1 root root 0 Jun 26 11:20 time
drwxr-xr-x. 6 root root 4096 Aug 1 2019 vmtools
-r--r--r--. 1 root root 18380837 May 7 17:09 vmtools-2.5.0.156.tar.bz2
[root@dev-yum-server ~]#
type 判断命令来源
[root@dev-yum-server ~]# type echo
echo is a shell builtin
[root@dev-yum-server ~]# type w
w is hashed (/bin/w)
[root@dev-yum-server ~]#
快捷方式
Ctrl + U:从光标位置删除到行首
Ctrl + K:从光标位置删除到行尾