我想在R中使用cat函数在文本文件中打印以下行:
shebang line
for file in *.out; do sed $'s/Cluster/\\\n&/g' $file > "$(basename "$file" .out)_split.out2"; done为此,我使用:
cat("shebang line","for file in *.out; do sed $'s/Cluster/\\\n&/g' $file > \"$(basename \"$file\" .out)_split.out2\"; done",file="output.txt",sep="\n",append=TRUE)但在output.txt中,我得到了:
shebang line
for file in *.out; do sed $'s/Cluster/\
&/g' $file > "$(basename "$file" .out)_split.out2"; done似乎它创建了一个额外的换行符,并且不在单引号内打印\n。考虑到我确实需要使用\n作为分隔符,如何在不创建换行符的情况下按原样打印字符?谢谢
发布于 2019-04-12 02:14:27
尝试:
cat("shebang line","for file in *.out; do sed $'s/Cluster/\\\\\\n&/g' $file > \"$(basename \"$file\" .out)_split.out2\"; done",file="output.txt",sep="\n",append=TRUE)
https://stackoverflow.com/questions/55638690
复制相似问题