[英]Write multiple lines to a file using bash for Mac
I am creating a bash file to be run in Mac PC.我正在创建一个要在 Mac PC 上运行的 bash 文件。 Basically the file creates and writes multiple lines to a file.
基本上,该文件会创建多行并将其写入文件。 It contains some special characters like tilde, percentage etc.
它包含一些特殊字符,如波浪号、百分比等。
Somehow in the file created, the characters sometimes disappears or appears wrong.不知何故,在创建的文件中,字符有时会消失或出现错误。 I am doing the standard echo line by line.
我正在逐行执行标准回声。 Eg
例如
echo text >> file.conf
Is there any other way to write to a file?有没有其他方法可以写入文件?
Try quoting your text.试着引用你的文字。 If you want variables expanded, use double quotes.
如果要扩展变量,请使用双引号。 If you do not want variables expanded, use single quotes:
如果不想扩展变量,请使用单引号:
echo "$HOME" # expanded
/Users/Mark
echo '$HOME' # not expanded
$HOME
echo * # expanded
0.jpg 0_0.jpg 0_1.jpg 0_10.jpg 0_11.jpg 0_12.jpg 0_2.jpg 0_3.jpg 0_4.jpg
echo '*' # not expanded
*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.