问题描述
我得到的名字开始为eg_一些文件。只有每个包含一个单行
i got some files with name start as eg_. and only each contains one single line
eg_01.txt:
@china:129.00
eg_01.txt:@china:129.00
eg_02.txt
@uk:219.98
eg_02.txt@uk:219.98
eg_03.txt
@USA:341.90
eg_03.txt@USA:341.90
......
我期待他们猫在一个单一一行像URL发送:
@china:129.00@uk:219.98@USA:341.90
i am expecting to cat them in to a single line to send by URL like:@china:129.00@uk:219.98@USA:341.90
我使用
回声如猫_ *
它给我的输出看起来像一个字符串,但它实际上包含了新行:
@china:129.00
it give me the output look like a string, but it actually contains new line:"@china:129.00
@uk:219.98
@USA:341.90
@uk:219.98@USA:341.90"
还有没有其他的办法可以构建一个字符串,它预计,摆脱新的生产线,甚至是空间?只有猫足以做到这一点?
is there any other way i can construct that string which expected and get rid of new line and even the space? is only cat enough to do this?
在此先感谢
推荐答案
您可以始终将其管 TR
tr "\n" " "
这消除了对标准输入
所有换行和用空格替换它们。
That removes all newlines on stdin
and replaces them with spaces
修改:由Bart SAS的建议,你也可以删除换行符与 TR -d
EDIT: as suggested by Bart Sas, you could also remove newlines with tr -d
tr -d "\n"
(注意:只要指定一个空字符串 TR
的第二个参数不会做)
这篇关于在单串的bash猫多个文件内容,而新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!