A******a 发帖数: 61 | 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. | b******y 发帖数: 9224 | 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... | c*****t 发帖数: 1879 | 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
|
|