Shell echo命令

Shell echo命令
echo "It is a test"  这里的双引号完全可以省略
3.显示变量
read 命令从标准输入中读取一行,并把输入行的每个字段的值指定给 shell 变量
  #!/bin/sh
  read name 
  echo "$name It is a test"
$ OK                     #标准输入
$ OK It is a test        #输出

显示不换行
#!/bin/sh
echo -e "OK! c" # -e 开启转义 c 不换行
echo "It is a test"
$ OK! It is a test

显示结果定向至文件  echo "It is a test" > myfile

原样输出字符串,不进行转义或取变量(用单引号)
echo '$name"'
输出结果:
$name"

显示命令执行结果
  echo `date`

怎样使用echo打印tab( )

1.在echo后面加一个-e 

 echo -e "${url} ${data}"

2.还有一种就是 写成$' '

echo "${url}"$' '"${data}"

 
原文地址:https://www.cnblogs.com/timssd/p/5297600.html