Jenkins 플러그인의 텍스트가 다음 형식으로 포함된 300줄이 넘습니다.
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
답변1
다음을 시도해 볼 수 있습니다.
$ sed 's/^.*(\([^()]*\)): \(.*\)$/- \1:\2/' 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.0
답변2
$ awk -F'[(): ]+' '{print "-", $(NF-1)":"$NF}' 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.0
답변3
해결책 gawk
:
awk -F'): ' -v OFS=':' '{ sub(/.*\(/, "", $1); print " - "$1,$2 }' file
답변4
awk -F ')' '
{
sub(/.*\(/, " - ", $(NF-1))
print $(NF-1) $(NF)
}
' file