How to make xargs read input from starting from specific line?

How to make xargs read input from starting from specific line?

Problem Description:

For example I use this command to list all containers of name django project
docker ps -q --filter "status = exited" --filter "name = django_project"
Problem is that I can’t remove the first line of output that looks like
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES and I want to use xargs to do things on my containers.

Googling. Really hard. But I didn’t find any elegant looking answer. I can do it using variable and trimming that first line but I want to keep my code as short as possible.

Solution – 1

Use

docker ps -q --filter "status = exited" --filter "name = django_project" | tail -n +2 | xargs ...

to remove the first line of output

Rate this post
We use cookies in order to give you the best possible experience on our website. By continuing to use this site, you agree to our use of cookies.
Accept
Reject