Redian新闻
>
how to use grep/sed to remove newlines? (转载)
avatar
how to use grep/sed to remove newlines? (转载)# Java - 爪哇娇娃
A*a
1
【 以下文字转载自 Linux 讨论区 】
发信人: Ataraxia (静), 信区: Linux
标 题: how to use grep/sed to remove newlines?
发信站: BBS 未名空间站 (Sat Oct 18 10:48:52 2008)
i am trying grep some text from a file then return some words:
grep "^>start" textfile.txt
but it always returns results one each line:
A
B
C
I want to have it as: A B C ..., so I tried to use sed:
grep "^>start" textfile.txt | sed -e 's/\n//'
it doesn't work, anyone knows how to solve this?
Thanks.
avatar
b*y
2
use java to write a simple program to do that ;-)
BufferedReader to read in file line by line,
BufferedWriter to spool/write file out line by line to a new file.
Problem solved...
avatar
c*t
3
echo `grep ">start" textfile.txt`

【在 A******a 的大作中提到】
: 【 以下文字转载自 Linux 讨论区 】
: 发信人: Ataraxia (静), 信区: Linux
: 标 题: how to use grep/sed to remove newlines?
: 发信站: BBS 未名空间站 (Sat Oct 18 10:48:52 2008)
: i am trying grep some text from a file then return some words:
: grep "^>start" textfile.txt
: but it always returns results one each line:
: A
: B
: C

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。