- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一堆文本文件,在 80 个字符处有硬换行符。我想“取消填充”(使用 emacs 术语)这些段落,这样每个段落都是一行,以便更容易地将这些文件中的文本复制和粘贴到其他应用程序中。有没有办法用 shell 脚本做到这一点?
例如,我有如下所示的输入文本:
Call me Ishmael. Some years ago- never mind how long precisely- having little or
no money in my purse, and nothing particular to interest me on shore, I thought
I would sail about a little and see the watery part of the world. It is a way I
have of driving off the spleen and regulating the circulation. Whenever I find
myself growing grim about the mouth; whenever it is a damp, drizzly November in
my soul; whenever I find myself involuntarily pausing before coffin warehouses,
and bringing up the rear of every funeral I meet; and especially whenever my
hypos get such an upper hand of me, that it requires a strong moral principle
to prevent me from deliberately stepping into the street, and methodically
knocking people's hats off- then, I account it high time to get to sea as soon
as I can. This is my substitute for pistol and ball. With a philosophical
flourish Cato throws himself upon his sword; I quietly take to the ship.
There is nothing surprising in this. If they but knew it, almost all men in
their degree, some time or other, cherish very nearly the same feelings towards
the ocean with me.
There now is your insular city of the Manhattoes, belted round by wharves as
Indian isles by coral reefs- commerce surrounds it with her surf. Right and
left, the streets take you waterward. Its extreme downtown is the battery,
where that noble mole is washed by waves, and cooled by breezes, which a few
hours previous were out of sight of land. Look at the crowds of water-gazers
there.
我希望输出文本看起来像:
Call me Ishmael. Some years ago- never mind how long precisely- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off- then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.
There now is your insular city of the Manhattoes, belted round by wharves as Indian isles by coral reefs- commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.
有没有办法使用 shell 脚本来做到这一点?我觉得 sed
应该能够做到这一点,但我不确定具体的命令是什么让它连接段落,而不是拆分它们。
最佳答案
使用 (g)awk
awk -vRS= -vORS= '{gsub("\n","")}{print $0 RT}' file
按段落拆分记录并从记录中删除所有换行符。
用 perl
perl -pe '/^$/?print:chomp' file
关于bash - 用shell脚本批量处理 "unfill"段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38474547/
我有一堆文本文件,在 80 个字符处有硬换行符。我想“取消填充”(使用 emacs 术语)这些段落,这样每个段落都是一行,以便更容易地将这些文件中的文本复制和粘贴到其他应用程序中。有没有办法用 she
我有这个表单元素: $form->input('ChecklistResponseGovernmentInfo.driversLicenseIsOnline', array('type'=>'radi
由于 g() 中缺少 f() 的参数,下面的代码会在 PyCharm 中产生一个可视的黄色警告。 def f(b): return b def g(): return f() #
我正在尝试绘制未填充的符号,但 matplotlib facecolors='none' 参数似乎只是改变了填充颜色。请注意,我使用的是 matplotlib 样式的“ggplot”。 带有填充符号的
我正在尝试创建一个 CSS 进度条,但是由于某种原因,UNFILL 部分(白色背景)没有与作为 FILL 部分的绿色背景重叠。 知道怎么做吗? 还有,由于这是 @Keyframe CSS3,这应该只适
我写了一个 MySQL 更新语句,它从一个 csv 文件更新一个表。当从 phpMyAdmin 运行时,此命令完美运行,但当尝试从 php 运行时,它失败了。它说我的语法有错误。 这是我的 php 代
关闭。这个问题需要debugging details .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve this questio
我的程序中有一个名为 Page 的类。它有 10 个属性,但在某些时候,只需要 3 个属性(RawPage),而在其他时候,所有或几乎所有属性都需要(ProcessedPage)。 我只有一个具有所有
我是一名优秀的程序员,十分优秀!