Svn status | sort - does not sort the output

I would like to sort the svn status output, but somehow this command

 svn status | sort 

doesn't sort the output. Do you know, why?

eg:

 $ 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 

question marks are not sorted, for example.

+6
source share
1 answer

It seems you want sort disable the last resort comparison.

Speaking

 sort -s -k1,1 

for your input:

 ! 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 

Quote man sort :

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

From sort call :

Finally, in the extreme case, when all keys are compared equal, sorting compares whole lines, as if not order parameters, except --reverse (-r) were specified. The --stable (-s) disables this last comparison mode so that lines in which all fields are compared equal remain in their original relative order.

+1
source

Source: https://habr.com/ru/post/958300/


All Articles