首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bash -将文件中的每个句子放在不同的行中。

Bash -将文件中的每个句子放在不同的行中。
EN

Stack Overflow用户
提问于 2022-08-17 18:50:45
回答 1查看 50关注 0票数 0

我需要阅读文本文件中每个句子的长度。

我计划在不同的行上把每个句子分开,然后读每一行。

代码语言:javascript
复制
# LineSplitter

File="NameOfFile"

while read -r line; do
    # check the neght of $line
done <$file

我尝试使用tr来代替\n.,但这删除了.,不适用于提问。

LineSplitter的解决方案?

应该是这样的

初始档案:

代码语言:javascript
复制
SMS marketing is an excellent customer service tool because messages are delivered and read almost immediately — and there’s room for two-way communication. And SMS customer service can be scaled and automated. Plus, if you leverage this channel, your business will save money on phone service and customer service personnel training.


See a few templates for customer support messages below.

最终

代码语言:javascript
复制
SMS marketing is an excellent customer service tool because messages are delivered and read almost immediately — and there’s room for two-way communication.
And SMS customer service can be scaled and automated.
Plus, if you leverage this channel, your business will save money on phone service and customer service personnel training.
See a few templates for customer support messages below.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-17 19:10:20

使用sed

代码语言:javascript
复制
$ sed 's/\. /&\n/g' input_file
SMS marketing is an excellent customer service tool because messages are delivered and read almost immediately — and there’s room for two-way communication. 
And SMS customer service can be scaled and automated. 
Plus, if you leverage this channel, your business will save money on phone service and customer service personnel training. 
See a few templates for customer support messages below.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73393586

复制
相关文章

相似问题

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