由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - 用sed 如何把多个空行并成一行.
相关主题
如何把一个binary file变回成text file?ultraedit for linux有了?
[转载] how to read Unix data file in PC?Help on shell script
edit tool in unixemacs中如何去指定一行
unix下读binary和windows读binary有区别吗?socket编程问题
hex edit in xemacs?How to test an empty string in shell
Read Unix mails in WindowsVI 一问
[转载] 在vi里怎样把一个字符串换成换行符?怎么把UNIX下文件转成LINUX下的文件 (转载)
unix下有类似ultraedit的基于列的编辑器?初级awk问题
相关话题的讨论汇总
话题: testtest话题: sed话题: 并成话题: 空行话题: empty
进入Unix版参与讨论
1 (共1页)
a**n
发帖数: 313
1
用sed 如何把多个空行并成一行.
==============================
testtest
testtest
=============================
变成:
==============================
testtest
testtest
=============================
thanks
c**o
发帖数: 166
2
I did that in perl and failed doing that in sh. :)

【在 a**n 的大作中提到】
: 用sed 如何把多个空行并成一行.
: ==============================
: testtest
: testtest
: =============================
: 变成:
: ==============================
: testtest
: testtest
: =============================

c****j
发帖数: 258
3
sed -n '
#print first empty line
/^$/ p
#find next empty line, remove it
/^$/ {
N
s/.//
b Empty
}
#print non-empty lines
p
'
I don't like sed, but it can do something quite simply.
q*z
发帖数: 13362
4
sed '/^$/d;G' input

【在 a**n 的大作中提到】
: 用sed 如何把多个空行并成一行.
: ==============================
: testtest
: testtest
: =============================
: 变成:
: ==============================
: testtest
: testtest
: =============================

c****j
发帖数: 258
5
You append an empty line to each non-empties.

【在 q*z 的大作中提到】
: sed '/^$/d;G' input
a**n
发帖数: 313
6
Thanks, it works.

【在 c****j 的大作中提到】
: sed -n '
: #print first empty line
: /^$/ p
: #find next empty line, remove it
: /^$/ {
: N
: s/.//
: b Empty
: }
: #print non-empty lines

q*z
发帖数: 13362
7
as his example showing

【在 c****j 的大作中提到】
: You append an empty line to each non-empties.
c**t
发帖数: 2744
8
UltraEdit can do this easily

【在 a**n 的大作中提到】
: 用sed 如何把多个空行并成一行.
: ==============================
: testtest
: testtest
: =============================
: 变成:
: ==============================
: testtest
: testtest
: =============================

1 (共1页)
进入Unix版参与讨论
相关主题
初级awk问题hex edit in xemacs?
在美国插管吸血之:一行代码多少钱 (转载)Read Unix mails in Windows
什么是悲愤体?[转载] 在vi里怎样把一个字符串换成换行符?
[合集] Re: GPS 软硬件unix下有类似ultraedit的基于列的编辑器?
如何把一个binary file变回成text file?ultraedit for linux有了?
[转载] how to read Unix data file in PC?Help on shell script
edit tool in unixemacs中如何去指定一行
unix下读binary和windows读binary有区别吗?socket编程问题
相关话题的讨论汇总
话题: testtest话题: sed话题: 并成话题: 空行话题: empty