shell-awk-打印进程ID

docker ps | grep cita | awk -F " " '{print $1}'

awk -F " " 按空格分割


e.g.

[root@host-10-0-169-67 ~]# sudo docker ps
CONTAINER ID        IMAGE                                              COMMAND                  CREATED             STATUS              PORTS                            NAMES
2b9c3949f316        registry.aliyuncs.com/glodonedu/glodontomcat:8.7   "/bin/sh -c '/usr/..."   6 months ago        Up 6 months         22/tcp, 8080/tcp, 8251/udp       cocky_shannon
43c23bfd0598        sonatype/nexus3                                    "sh -c ${SONATYPE_..."   7 months ago        Up 7 months         0.0.0.0:8886->8081/tcp           nexus4
5bc98d2008a9        registry.aliyuncs.com/glodonedu/rabbitmq:3.5       "/bin/sh -c '/usr/..."   7 months ago        Up 7 months                                          rabbitmq
a7e6a52127fe        registry.aliyuncs.com/glodonedu/dubbo_admin:2.5    "/bin/sh -c '/usr/..."   7 months ago        Up 7 months         22/tcp, 0.0.0.0:8081->8080/tcp   dubbo_admin
7b3cf71a9858        registry.aliyuncs.com/glodonedu/zookeeper:3.4      "/bin/sh -c '/usr/..."   7 months ago        Up 7 months                                          zookeepe
[root@host-10-0-169-67 ~]# sudo docker ps | grep aliyuncs | awk -F " " '{print $1}'
2b9c3949f316
5bc98d2008a9
a7e6a52127fe
7b3cf71a9858
posted @ 2023-02-28 11:02  艺言弈行  阅读(23)  评论(0编辑  收藏  举报