bash 打印输出到文件
In Bash, how to print a string as a line to STDOUT? That is, the string and the newline character, nicely?
在bash,如何打印一个字符串作为一行STDOUT ? 也就是说,字符串和换行符很好吗?
And similarly, how to print the line to STDERR?
同样,如何将行打印到STDERR?
In Bash, you can simply use the echo
command:
在Bash中 ,您可以简单地使用echo
命令:
echo "your message here"
or
要么
echo your message here
Examples:
例子:
$ echo the message here
the message here
$ echo "the message here"
the message here
$ echo `date`
Fri Apr 7 13:40:20 HKT 2017
$
To STDERR:
前往STDERR:
In Bash:
在Bash中 :
1>&2 echo "msg to STDERR"
The 1>&2
redirects STDOUT to STDERR.
1>&2
将STDOUT重定向到STDERR。
Answered by dtivl.
dtivl回答。
翻译自: https://www.systutorials.com/how-to-print-a-line-to-stderr-and-stdout-in-bash/
bash 打印输出到文件