[英]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
列不能有None
或null
值。
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.