shell - Shell:在字母数字字符后添加换行符
问题描述
我需要在以下段落中的字母数字字符(例如:11.34s)之后添加一个换行符 - 在 Shell 中
输入:
zip_upload : Unzipping the new release at /path - 338.17s Gathering Facts --------------------------------------------------------- 4.78s zip_upload : Upload the zipped binaries to repository ---------- 2.48s zip_upload : Find the file applicatons.yml in remote node ------ 1.87s zip_upload : Upload to repository ---------------------- 0.92s zip_upload : include_tasks ------------------------------------------- 0.71s
需要的输出如下:
zip_upload : Unzipping the new release at /path - 338.17s
Gathering Facts --------------------------------------------------------- 4.78s
zip_upload : Upload the zipped binaries to repository ---------- 2.48s
zip_upload : Find the file applicatons.yml in remote node ------ 1.87s
zip_upload : Upload to repository ---------------------- 0.92s
zip_upload : include_tasks ------------------------------------------- 0.71s
请帮忙
解决方案
单程:
sed -r "s/([0-9]\.[0-9][0-9]s) /&\n/g" file
这个 sed 寻找一个模式[digit].[digit][digit]s
,然后用模式匹配(&
)替换,然后是换行(\n
)。
推荐阅读
- android - 如何禁用 OneSignal 通知弹出窗口?
- java - Spring-mvc 中的 JDBC 异常处理
- r - 数据帧作为 R 中 3D 矩阵中的第三维
- npm - npm - 通过多个脚本从 CLI 传递参数
- angular - PhantomJS/Chrome 在 Angular 6 项目中因“Zone\nat”/“脚本错误”而在 Karma 测试中失败
- wordpress - 仅在“pre_get_posts”钩子中查询带有特色图片的帖子
- api - 可以使用 Envoy Proxy 封装第三方 API 吗?
- vba - 将 Outlook 电子邮件另存为“.msg”而不是“文件”
- metadata - 元数据提取器——缺少标签列表?
- javascript - jQuery 到 Vanilla JS,删除