简体   繁体   English

如何以表格格式获取此输出

[英]How to get this output in table format

[root@sqlnode1 ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS                     NAMES
05dcc80854bc        ha_tomcat           "bin/catalina.sh run"    5 days ago          Exited (1) About an hour ago   0.0.0.0:8080->8080/tcp    tomcat
d6235e4da6dc        ha_elasticsearch    "/bin/bash"              5 days ago          Exited (0) 5 days ago                                    elasticsearch
ba270b98854a        ha_mysql            "/bin/sh -c 'service "   5 days ago          Created                                                  mysql
035473bf58eb        ha_redis            "/bin/sh -c 'redis-se"   5 days ago          Exited (1) About an hour ago   0.0.0.0:32768->6379/tcp   redis
2b83039b032e        3c42844f3642        "catalina.sh run"        9 days ago          Exited (1) 5 days ago          0.0.0.0:8888->8080/tcp    dreamy_einstein

this is the output .I want to keep as it is into a table format.这是输出。我想将其保留为表格格式。 But using below command I am getting this as output.但是使用下面的命令,我将其作为输出。

[root@sqlnode1 ~]# column -t outfile
CONTAINER     ID                IMAGE             COMMAND  CREATED     STATUS  PORTS   NAMES
05dcc80854bc  ha_tomcat         "bin/catalina.sh  run"     5           days    ago     Exited  (1)     About    an     hour           ago                     0.0.0.0:8080->8080/tcp  tomcat
d6235e4da6dc  ha_elasticsearch  "/bin/bash"       5        days        ago     Exited  (0)     5       days     ago    elasticsearch
ba270b98854a  ha_mysql          "/bin/sh          -c       'service    "       5       days    ago     Created  mysql
035473bf58eb  ha_redis          "/bin/sh          -c       'redis-se"  5       days    ago     Exited  (1)      About  an             hour                    ago                     0.0.0.0:32768->6379/tcp  redis
2b83039b032e  3c42844f3642      "catalina.sh      run"     9           days    ago     Exited  (1)     5        days   ago            0.0.0.0:8888->8080/tcp  dreamy_einstein

it is getting clustered after the columns..Hope you understand .Thanks它在列之后聚集在一起。希望你理解。谢谢

Your wish is not clearly understandable but for reaching every lines one by one awk 'NR==linenumber {print; exit}' filename您的愿望不是很清楚,而是为了逐行到达每一行awk 'NR==linenumber {print; exit}' filename awk 'NR==linenumber {print; exit}' filename , getting first,secon,third... value in specific line awk -F" " 'NR==linenumber {print $1; exit}' awk 'NR==linenumber {print; exit}' filename ,在特定行中获取第一个、第二个、第三个...值awk -F" " 'NR==linenumber {print $1; exit}' awk -F" " 'NR==linenumber {print $1; exit}' ,or while loop with first command.Do these commands in for loops then write your outputs to CVS file for table view. awk -F" " 'NR==linenumber {print $1; exit}' ,或 while 循环与第一个命令。在 for 循环中执行这些命令,然后将输出写入 CVS 文件以进行表视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM