首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在句子之间加上四行

在句子之间加上四行
EN

Unix & Linux用户
提问于 2018-10-14 11:34:00
回答 2查看 209关注 0票数 -1

是否有一种简单的方法在每个句子之间添加四个空行。

例如,这一段:

代码语言:javascript
复制
This combination of vitamins and selected minerals is used to prevent or treat vitamin 
deficiency due to poor eating habits, problems that affect the body's ability to absorb nutrition from food, or increased need for vitamins and minerals due to stress 
or illness. Vitamins are needed for the body to function well.
This vitamin/mineral combination contains high levels of B vitamins (e.g., folic acid, 
niacin, B-1, B-2, B-6, and B-12) and vitamin C. It also contains other vitamins (A, D, and E) and minerals such as zinc. This medication does not contain iron and has only a 
small amount of calcium. Therefore, it should not be used to treat "iron-poor" blood 
(anemia) or to prevent osteoporosis.

我怎样才能做到:

代码语言:javascript
复制
This combination of vitamins and selected minerals is used to prevent or treat vitamin 




deficiency due to poor eating habits, problems that affect the body's ability to absorb nutrition from food, or increased need for vitamins and minerals due to stress 




or illness. Vitamins are needed for the body to function well.




This vitamin/mineral combination contains high levels of B vitamins (e.g., folic acid, 




niacin, B-1, B-2, B-6, and B-12) and vitamin C. It also contains other vitamins (A, D, and E) and minerals such as zinc. This medication does not contain iron and has only a 




small amount of calcium. Therefore, it should not be used to treat "iron-poor" blood 




(anemia) or to prevent osteoporosis.

我想:

1-在每一行之间加四个空格。

2-在第一行后添加一个空格,然后每四个空格添加一段空格。

EN

回答 2

Unix & Linux用户

发布于 2018-10-14 11:38:34

sed能做到

代码语言:javascript
复制
sed 'G;G;G;G' file

说明:

根据sed人,标志G是将换行符附加到模式空间的内容,然后将保持空间的内容附加到模式空间的内容中。

在上面的命令中,每个G都会添加一个新行。

为了在第一行之后添加一个空格,然后每四行增加一个空空格,

在GNU系统中:

代码语言:javascript
复制
sed '1~4G' file

1~4意味着每四行首先匹配一行,因此上面的命令将开始在第一行之后创建空行,然后每四行创建一条空行。

票数 3
EN

Unix & Linux用户

发布于 2018-10-14 15:47:05

我通过下面的方法使用sed命令完成了

代码语言:javascript
复制
sed "s/.*/&\n\n\n\n/g" filename

测试和工作良好

票数 0
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/475398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档