如何有并排的sed的输出端? [英] How to have the sed output side by side?
问题描述
我希望有并排的基因放在一边KEGG通路标准输出无论KEGG多少行途径有。例如,一个基因TT123456是涉及在几个途径:
I want to have standard output for KEGG pathways of a gene placed side by side no matter how many lines of the KEGG pathways it has. For example, a gene TT123456 is involves in several pathways:
Valine, leucine and isoleucine degradation
Histidine metabolism
Ascorbate and aldarate metabolism
Lysine degradation
Glycerolipid metabolism
通过使用sed命令
By using the sed command
sed '$!N;s/\n/\t/'
我能有两行加入并排
I able to have two lines joined side by side
Valine, leucine and isoleucine degradation Histidine metabolism
Ascorbate and aldarate metabolism Lysine degradation
Glycerolipid metabolism
不过,我想有输出作为
But, I would like to have the output as
Valine, leucine and isoleucine degradation Histidine metabolism Ascorbate and aldarate metabolism Lysine degradation Glycerolipid metabolism
我一直在寻找身边,但我没能找到一个很好的解决方案。
I have been searching around, but, I failed to find a good solution.
能否社区请分享你的专业知识和我在一起?
Could the community please shares your expertise with me?
感谢您。
推荐答案
这是什么真正的 粘贴(1)
是:
This is really what paste(1)
is for:
$ paste -s "$file"
Valine, leucine and isoleucine degradation Histidine metabolism Ascorbate and aldarate metabolism Lysine degradation Glycerolipid metabolism
下面就是手册页说, -s
标志应该做的:
Here's what the manpage says the -s
flag should do:
串连所有在命令中的每个单独的输入文件的行的
线序。在<&换行符GT;
除了在每个最后一行每一行
标签> ,除非另有输入文件应与&LT被替换
由-d选项指定。
Concatenate all of the lines of each separate input file in command line order. The
<newline>
of every line except the last line in each input file shall be replaced with the<tab>
, unless otherwise specified by the -d option.
您也可以使用处理标准输入 -
而不是文件名
You can also process standard input by using a -
instead of the filename.
somecommand | paste -s -
这有什么区别 TR的'\\ n''\\ T'
和粘贴-S
(有一个隐含的标签分隔符)?前者将剥离甚至其后的换行符,但粘贴
会留下最后的换行符完好。此外,粘贴
可同时处理标准输入和文件,但 TR
可以的只有的处理标准输入。
What's the difference between tr '\n' '\t'
and paste -s
(with an implied tab delimiter)? The former will strip even the trailing newline, but paste
will leave the final newline intact. Also, paste
can handle both standard input and files, but tr
can only handle standard input.
这篇关于如何有并排的sed的输出端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!