Home > Enterprise >  How to make xargs read input from starting from specific line?
How to make xargs read input from starting from specific line?

Time:12-06

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.

CodePudding user response:

Use

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

to remove the first line of output

  • Related