sed - bash SED命令解释带分号
问题描述
这个 sed 命令在做什么?是否有任何在线实用程序可以稍微解释一下 sed,例如正则表达式?
sed -i '1s/$/|,a Type,b Type,c Type/;/./!b;1!s/$/|,,,/' textflile.txt
我认为一开始它是在行尾添加 csv a type, b type, c type 但命令的其余部分也是什么
解决方案
我不知道任何此类实用程序,但让我使用文本编辑器进行解释:
sed -i '1s/$/|,a Type,b Type,c Type/;/./!b;1!s/$/|,,,/' textflile.txt
^ ^ ^ ^ ^^ ^^ ^
| | | | || || |
modify | End Non-empty || || input
the | of lines || |Negation, file
file | line only || |i.e. lines 2,3,...
in | || |
place | || First
First line Negation, i.e.| line
empty lines only|
Branch to
script end,
i.e. skip the rest
换句话说,它添加|,a type, b Type,c Type
到第一行,不更改空行,并添加|,,,
到所有剩余的行。
推荐阅读
- javascript - 从javascript中的2个数组对象中获取不匹配的数据
- php - 我有问题从mysql按年分组数据值
- vim - Vim 获取/设置缓冲区名称而不输入缓冲区
- notepad++ - Notepad++ - 将来自 SQL Server 的大查询变成一行
- sql-server - Oracle Varchar2 到 SQL Server Varchar
- php - PHP 错误页面(自定义)
- docker - ddev start 报错:当前安装的 docker 版本不符合 ddev 的要求:17.6.2-ce is less than 18.06.0-ce
- robots.txt - Googlebot 无法获取此页面的所有资源
- azure - Application Insight 日志 403
- responsive-design - Bootstrap 4.1 carousel-fade 响应式图像效果