echo命令你真的会用了么?

版权声明:如若转载,请联系作者。 https://blog.csdn.net/liu16659/article/details/85266963

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

猜你喜欢

转载自blog.csdn.net/liu16659/article/details/85266963