[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
这是输出。我想保持原样表格格式。但是使用下面的命令我得到它作为输出。
[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
它会在列之后聚集。希望你明白。谢谢
答案 0 :(得分:0)
你的愿望不是很清楚,但是
逐个到达每一行awk 'NR==linenumber {print; exit}' filename
,
获取first,secon,third ...特定行awk -F" " 'NR==linenumber {print $1; exit}'
中的值,或带第一个命令的while循环。在for循环中执行这些命令然后将输出写入CVS文件以进行表视图。