Search code examples
bashdockersedgrepcut

Cutting / Formatting a docker service command


Sorry for the imprecise title but i'm actually working on the simpliest way to cut this:

Docker service ls

Into this:

Docker service ls cutted

Tried with some -f but not working. Maybe with some grep/sed/cut stuff but i didnt find a satisfying way...

Thanks a lot for the time


Solution

  • You can use awk

    docker service ls | awk -F" " '{print $2, $4}'