tr 命令不起作用
大家好,这里有一个问题。我有一个文件,其中有一些数据,例如
- 芒果
- 苹果
- 橙
- 葡萄
当我运行命令时
tr '\n' ' ' < file.txt
它工作正常; 输出是:
mango apple orange grapes
但我有另一个文件,其中包含类似
- 12029
- SIDRASHAHID
- 7(outof471)
的数据,但上述命令不起作用。问题是文件中有数值数据吗?
我什至尝试过 sed 但失败了。
谁能告诉我是否有一种方法可以将这些数据写入一行?
Hello every one here I have a problem. I have a file in which there is some data like this
- mango
- apple
- orange
- grapes
When I run the command
tr '\n' ' ' < file.txt
It works fine;
the output was:
mango apple orange grapes
but I have another file which has data like this
- 12029
- SIDRASHAHID
- 7(outof471)
but the above command is not working on it. Is the problem that the file has numerical data?
I have even tried sed but failed.
Can any one tell me if there is a way by which I can write this data into a single line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将评论转换为答案,因为它似乎是准确的:
Converting a comment into an answer since it seems to be accurate:
使用
echo $()
:如果您仍然想要使用
sed
,您可以:use
echo $()
:If you still would like to use
sed
, you can:试试这个:
try this: