由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - how to use grep/sed to remove newlines? (转载)
相关主题
问一个blocking IO的程序面试题,不知道怎么答好
大家在工作中遇到过什么很难的问题(技术上)Issue when running a unix command with Runtime.getRuntime.exec()
随机读一个大文件中的任意一行how to solve the problem: the members change by each other .
System.in如何使用UTF-8?help! string format???
Problem solved by Re: Desperately need help on DB2 connection through jdbc in jsp page请教一个问题,thanks!
please help me to solve this question!BufferedWriter里的write()
java dumb question急问如何append double 数据到txt文件
我想把一个Arraylist转成String[]Java练习题 8
相关话题的讨论汇总
话题: grep话题: sed话题: newlines话题: use话题: remove
进入Java版参与讨论
1 (共1页)
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

1 (共1页)
进入Java版参与讨论
相关主题
Java练习题 8Problem solved by Re: Desperately need help on DB2 connection through jdbc in jsp page
如何关闭打开的输入输出?please help me to solve this question!
Re: Need Emergent help for Java I/O!java dumb question
怎么从键盘输入整数或float?我想把一个Arraylist转成String[]
问一个blocking IO的程序面试题,不知道怎么答好
大家在工作中遇到过什么很难的问题(技术上)Issue when running a unix command with Runtime.getRuntime.exec()
随机读一个大文件中的任意一行how to solve the problem: the members change by each other .
System.in如何使用UTF-8?help! string format???
相关话题的讨论汇总
话题: grep话题: sed话题: newlines话题: use话题: remove