在这个模式中,我有300多行包含Jenkins插件的文本:
Server Sent Events (SSE) Gateway Plugin (sse-gateway): 1.24
Common API for Blue Ocean (blueocean-commons): 1.24.4
Handy Uri Templates 2.x API Plugin (handy-uri-templates-2-api): 2.1.8-1.0
Durable Task Plugin (durable-task): 1.35
Git Pipeline for Blue Ocean (blueocean-git-pipeline): 1.24.0
REST API for Blue Ocean (blueocean-rest): 1.24.4
Terraform Plugin (terraform): 1.0.10
GIT server Plugin (git-server): 1.9
Web for Blue Ocean (blueocean-web): 1.24.0
Bitbucket Pipeline for Blue Ocean (blueocean-bitbucket-pipeline): 1.24.0我正在寻找一种方法来修剪不必要的文本,例如使用sed或awk之类的工具,结果如下:
- plugin-util-api:1.7.0
- blueocean-pipeline-api-impl:1.24.0
- credentials-binding:1.24
- Pipelineworkflow-aggregator:2.6
- hashicorp-vault-plugin:3.6.1
- matrix-project:1.18
- blueocean-display-url:2.4.1
- structs:1.21发布于 2021-03-03 08:01:39
每一行替换两次:
(的所有内容。):后面的空格。$ sed 's/.*(/- /; s/): /-/' file
- sse-gateway-1.24
- blueocean-commons-1.24.4
- handy-uri-templates-2-api-2.1.8-1.0
- durable-task-1.35
- blueocean-git-pipeline-1.24.0
- blueocean-rest-1.24.4
- terraform-1.0.10
- git-server-1.9
- blueocean-web-1.24.0
- blueocean-bitbucket-pipeline-1.24.0https://unix.stackexchange.com/questions/637272
复制相似问题