我想排序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.