LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 790|回复: 5

如何将输出"回车"代替为输出"空格" ?

[复制链接]
发表于 2004-6-28 10:49:10 | 显示全部楼层 |阅读模式
例如有一文本输出为
one
two
three
four
five
six
如何使它输出为
one two three four five six

谢谢!
发表于 2004-6-28 11:52:39 | 显示全部楼层
cat file | tr '\n' ' '
发表于 2004-6-28 16:17:59 | 显示全部楼层
try for:
[php]for line in $(<file);do echo -n "$line ";done;echo[/php]
发表于 2004-6-28 16:50:54 | 显示全部楼层
in vi:

  1. :%s/\n/ /
  2. :wq!
复制代码
发表于 2004-6-28 19:09:14 | 显示全部楼层

回复: 如何将输出&quot;回车&quot;代替为输出&quot;空格&quot; ?

最初由 gdlwx 发表
例如有一文本输出为
one
two
three
four
five
six
如何使它输出为
one two three four five six

谢谢!
  1. echo $(< /your/file)
复制代码
发表于 2004-6-28 19:34:34 | 显示全部楼层

回复: 回复: 如何将输出&quot;回车&quot;代替为输出&quot;空格&quo

最初由 dearvoid 发表
  1. echo $(< /your/file)
复制代码

这个最绝!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表