The best Shell echo command Tutorial In 2024, In this tutorial you can learn Shell echo command
Similar to Shell's echo command and PHP's echo command is used to output strings. Format:
echo string
You can use more complex echo control the output format.
echo "It is a test"
Double quotes can be omitted here entirely consistent with the examples above, the effect of the following commands:
echo It is a test
echo "\"It is a test\""
The result will be:
"It is a test"
Similarly, double quotation marks can be omitted
read command reads a line from standard input, and to specify the values for each field in the input line to the shell variable
#!/bin/sh read name echo "$name It is a test"
Save the above code test.sh, name receive standard input variables, the result will be:
[root@www ~]# sh test.sh OK #标准输入 OK It is a test #输出
echo -e "OK! \n" # -e 开启转义 echo "It it a test"
Output:
OK! It it a test
#!/bin/sh echo -e "OK! \c" # -e 开启转义 \c 不换行 echo "It is a test"
Output:
OK! It is a test
echo "It is a test" > myfile
echo '$name\"'
Output:
$name\"
echo `date`
The results will show the current date
Thu Jul 24 10:08:46 CST 2014