用带有转义字符的记录填充文件

用带有转义字符的记录填充文件

我有一份 csv 记录:

"[email protected]","456281438","16274","782981244047720"," ","<table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"" align=""center"" style=""font-size:0;""><tr>","","","","",""

我需要填充文件,直到达到指定的文件大小。我会使用一个简单的循环来附加同一行。有没有办法用 echo 只写这一行,包括"遇到的每一行?

如果我用echo -e我得到

eianni@ianni-desktop:~/Desktop$ echo -e "[email protected]","456281438","16274","782981244047720"," ","<table cellpadding=""0"" cellspacing=""0"" border=""0"" width=""100%"" align=""center"" style=""font-size:0;""><tr>","","","","",""
[email protected],456281438,16274,782981244047720, ,<table cellpadding=0 cellspacing=0 border=0 width=100% align=center style=font-size:0;><tr>,,,,,

答案1

您可以通过将整个参数括echo在单引号中来阻止 bash 处理引号。
echo -e '"0258327... .."",""'应该可以解决问题。

相关内容