如何修复 echo 打印字面 (反斜杠换行符)
问题:
你想像这样 echo 到文件:
echo_example.sh
echo "\ntest\n" > test.txt但执行此操作后,test.txt 包含字面
echo_literal_output.txt
\ntest\n解决方案
使用 echo -e(-e 表示:解释反斜杠转义):
echo_fix.sh
echo -e "\ntest\n" > test.txt执行此操作后,test.txt 将包含前后都有换行符的 test。
Check out similar posts by category:
Linux
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow