zl程序教程

您现在的位置是:首页 >  工具

当前栏目

echo命令你真的会用了么?

命令 真的 Echo 会用
2023-09-14 09:13:15 时间

echo命令你真的会用了么?

1. 简单使用

  • 输出后接字符串
  • 输出变量值

3. 常遇问题

  • echo 一个变量之后,失去了换行符。
    解决办法: 将 echo $var 替换成 echo "$var" 接口
    示例如下:
[root@server4 shells]# cat log.txt 
2 this is a test
3 Are you like awk
This's a test
10 There are orange,apple,mongo
[root@server4 shells]# res=`cat log.txt`
[root@server4 shells]# echo $res
2 this is a test 3 Are you like awk This's a test 10 There are orange,apple,mongo
[root@server4 shells]# echo "$res"
2 this is a test
3 Are you like awk
This's a test
10 There are orange,apple,mongo