【发布时间】:2018-09-19 19:00:30
【问题描述】:
我想将变量、字符串和新行的 printf 打印到 bash 中的文件中,并且在一行中。我会使用 echo,但 echo 似乎有不同的解释,并且在其他问题上推荐了 printf。
NAME="karl"
printf %"s\n" this is $(NAME) hello! > my_file
当我执行cat my_file 时,我希望它如下所示:
this
is
karl
hello!
【问题讨论】:
标签: bash