2017-08-11 115 views
-1
[[email protected] ~]# 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 

這是輸出結果。我想保留它作爲表格格式。但使用下面的命令我得到這個作爲輸出。如何以表格格式獲得此輸出

[[email protected] ~]# 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 

它是獲得columns..Hope後聚集你瞭解.Thanks

+4

您的初始輸出已經以表格格式 – RomanPerekhrest

+1

您不清楚如何修改碼頭輸出 –

回答

0

你的願望是沒有明確的理解,但 由一個awk 'NR==linenumber {print; exit}' filename, 獲得第一,塞康,第三到達每一個行。 ..在特定行awk -F" " 'NR==linenumber {print $1; exit}'中的值,或while循環與第一個命令。在for循環中執行這些命令,然後將您的輸出寫入CVS文件以進行表視圖。