简体   繁体   English

ubuntu 环境中打开堆栈服务器列表中的排序命令问题

[英]Issue with the sort command in open stack server list in an ubuntu environment

I am trying to sort the output here as per compute systems:我正在尝试根据计算系统对此处的输出进行排序:

在此处输入图像描述

I tried with openstack server list --all --long -c ID -c Name -c Status -c Host | sort -k4我尝试使用openstack server list --all --long -c ID -c Name -c Status -c Host | sort -k4 openstack server list --all --long -c ID -c Name -c Status -c Host | sort -k4 but it doesn't work. openstack server list --all --long -c ID -c Name -c Status -c Host | sort -k4但它不起作用。

Can someone help me how to can I sort this as per Host name?有人可以帮我如何根据主机名对其进行排序吗? where 460001 number is in ascending order under Host column.其中 460001 数字在主机列下按升序排列。

PS: the below is sample and is not an actual output from any anywhere. PS:以下是示例,不是任何地方的实际输出。

Regards, Tayto问候, 泰托

Just append --sort-column Host to your openstack command .只需将--sort-column Host附加到您的openstack command But you should make sure that the Host column can't have None or null value.但是您应该确保Host列不能有Nonenull值。

Check from openstack server list -h :openstack server list -h检查:

output formatters:
  output formatter options

  -f {csv,json,table,value,yaml}, --format {csv,json,table,value,yaml}
                        the output format, defaults to table
  -c COLUMN, --column COLUMN
                        specify the column(s) to include, can be repeated to
                        show multiple columns
  --sort-column SORT_COLUMN
                        specify the column(s) to sort the data (columns
                        specified first have a priority, non-existing columns
                        are ignored), can be repeated

Or if you don't have --sort-column option, you should sort -k8 but not -k4 .或者,如果您没有--sort-column选项,您应该sort -k8而不是-k4

Or use openstack server list --all --long -c ID -c Name -c Status -c Host -f value | sort -k4或者使用openstack server list --all --long -c ID -c Name -c Status -c Host -f value | sort -k4 openstack server list --all --long -c ID -c Name -c Status -c Host -f value | sort -k4 just with -f value , but it will separate the columns by blank space. openstack server list --all --long -c ID -c Name -c Status -c Host -f value | sort -k4仅使用-f value ,但它将用空格分隔列。

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

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