Listing Docker Images without registry URI I have a private container registry behind a firewall that will need some Google registry images. To make sure things are updated sanely, I'm writing a mirror script in Bash. I have one line that lists the images without their registry URIs, but it's overly complicated and I am piping through 3 awk statements.

docker images | awk '{printf("%s\:%s\n", $1, $2)}' | awk 'NR&gt;1' | awk -F '/' '{print $3}'


First awk statement:

$ docker images | awk '{printf("%s\:%s\n", $1, $2)}'
REPOSITORY:TAG
gcr.io/google_containers/skydns:2015-10-13-8c72f8c


Second awk statement:

$ docker images | awk '{printf("%s\:%s\n", $1, $2)}' | awk 'NR&gt;1'
gcr.io/google_containers/skydns:2015-10-13-8c72f8c


Third awk statement:

$ docker images | awk '{printf("%s\:%s\n", $1, $2)}' | awk 'NR&gt;1' | awk -F '/' '{print $3}'
skydns:2015-10-13-8c72f8c


How can I reduce this to one awk statement?
It looks like the purpose of the second command is to skip the REPOSITORY:TAG table header, which would always be the first line of the docker images output.  You can therefore combine the first two awk commands as:

awk 'NR &gt; 1 { printf("%s:%s\n", $1, $2) }'


To keep just the trailing part of the REPOSITORY field, you could do gsub('.*/', '', $1).  Note that that is not the same as awk -F '/' '{print $3}', but likely better.

Therefore, I would write the solution as

docker images | awk 'NR &gt; 1 { gsub('.*/', '', $1); printf("%s:%s\n", $1, $2); }'