linux – svn status | sort – 不对输出进行排序

前端之家收集整理的这篇文章主要介绍了linux – svn status | sort – 不对输出进行排序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想排序svn状态输出,但不知何故这个命令

svn status | sort

不排序输出.
你知道为什么吗?

例如:

$svn status 
?       idrd
?       core.7319
?       difftest
?       core.29328
A  +    rf_common/ext_api.sav
D       rf_common/ext_api/firewall_defs.h
D       rf_common/ext_api/rf_macro.h
?       firewall/src/hash2tuple.cpp.sav
!       firewall/src/hash2tuple.cpp
M       main.cpp
M       makefile

$svn status | sort
A  +    rf_common/ext_api.sav
?       core.29328
?       core.7319
?       difftest
D       rf_common/ext_api
D       rf_common/ext_api/firewall_defs.h
D       rf_common/ext_api/rf_macro.h
!       firewall/src/hash2tuple.cpp
?       firewall/src/hash2tuple.cpp.sav
?       idrd
M       main.cpp
M       makefile

例如,问号没有排序.

最佳答案
您似乎希望排序禁用最后的比较.

sort -s -k1,1

你的输入会产生:

!       firewall/src/hash2tuple.cpp
?       idrd
?       core.7319
?       difftest
?       core.29328
?       firewall/src/hash2tuple.cpp.sav
A  +    rf_common/ext_api.sav
D       rf_common/ext_api/firewall_defs.h
D       rf_common/ext_api/rf_macro.h
M       main.cpp
M       makefile

引用男人排序:

   -s,--stable
          stabilize sort by disabling last-resort comparison

sort invocation开始:

Finally,as a last resort when all keys compare equal,sort compares
entire lines as if no ordering options other than --reverse (-r)
were specified. The --stable (-s) option disables this last-resort
comparison so that lines in which all fields compare equal are left in
their original relative order.

原文链接:/linux/441074.html

猜你在找的Linux相关文章