跳转至

9. 内置命令

3.9 内置命令------echo,eval,exec,export,read,shift

- echo
- eval
- exec
- export
- read
- shift

3.9.1 echo

echo -n     #不换行输出
echo -e     #解析字符串中的特殊符号

#特殊符号
\n  换行
\r  回车
\t  制表符
\b  退一格

echo -n案例

[root@151 ~]# echo hello;echo world
hello
world
[root@151 ~]# echo -n hello;echo -n world
helloworld[root@151 ~]#

echo -e案例,作用与printf类似

[root@151 ~]# echo -e "hello\nworld"
hello
world
[root@151 ~]# printf "hello\nworld"
hello
world[root@151 ~]#

3.9.2 eval

执行多个命令

[root@151 ~]# eval ls;cd /tmp
anaconda-ks.cfg  kubeadm.yaml  nohup.out  test1.sh  test2.sh  test.sh
[root@151 tmp]#

3.9.3 exec

不创建子进程执行后续命令,且执行完毕后自动exit

[root@151 ~]# exec date
Fri Apr  2 01:22:56 CST 2021

────────────────────────────────────────────────────────────────────────────────

Session stopped
    - Press <return> to exit tab
    - Press R to restart session
    - Press S to save terminal output to file

最后更新: 2022-02-19 13:59:07