'docker -ps --format output with substr
There is a command: docker ps --format "{{.ID}}\t{{.Command}}" --no-trunc (used https://pkg.go.dev/text/template)
which outputs the full text of the '{{.Command}}' (which I need), but outputs too long '{{.ID}}'
I need to take the first 12 characters from '{{.ID}}' and all characters (--no-trunc) from '{{.Command}}'. How to do it?
Solution 1:[1]
You can use the ´printf` function in the Go template like this
docker ps --format "{{printf \"%.12s\" .ID}}\t{{.Command}}" --no-trunc
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hans Kilian |
