<分区>
如何将包含换行符分隔内容的文件转换为如下所示的单行?
blah
blah
进入
blah\nblah
标签 bash
<分区>
如何将包含换行符分隔内容的文件转换为如下所示的单行?
blah
blah
进入
blah\nblah
最佳答案
或 sed:
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\n/g'
(来自其他问题的@kenorb How can I replace a newline (\n) using sed?)
关于Bash 将多行字符串转换为单个换行符分隔的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39048277/
相关文章:
bash - 为什么 Bash 中的 [ -f ${x} ] 对于空 x 计算结果为 true?
linux shell - 检查今天的文件,如果今天没有就上传到hdfs 如果不是今天就不要上传。给出文件已存在的消息
bash - .bash_profile PS1 显示当前目录文件夹和 $ MAC osx
linux - 在单个别名命令中链接 xwininfo 和 imagemagick?
linux - 在 Linux 中使用 Bash 列出带空格的目录
linux - 为 Bash 脚本组织多个文件路径的最佳实践