[opensuse] sort using tab delimiter
I'm trying to sort a file using tab as a delimiter and had no success. I can change the tab to ":" delimiter and sort that way but can't sort using tab. jozien -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 06/09/2014 09:56 PM, Joe Zien wrote:
I'm trying to sort a file using tab as a delimiter and had no success. I can change the tab to ":" delimiter and sort that way but can't sort using tab.
http://stackoverflow.com/questions/1037365/unix-sort-with-tab-delimiter http://robfelty.com/2008/07/14/sort-using-tab-as-field-separator-in-bash The dollar sign tells bash to use ANSI-C quoting -- /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Joe Zien wrote:
I'm trying to sort a file using tab as a delimiter and had no success. I can change the tab to ":" delimiter and sort that way but can't sort using tab.
jozien
sort -t "^I" Where ^I = ctrl-I in the future, try reading the man page. man sort It took me all of 15 seconds to find that the -t flag allows you to choose a field separator. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 06/10/2014 03:56 AM, Joe Zien wrote:
I'm trying to sort a file using tab as a delimiter and had no success. I can change the tab to ":" delimiter and sort that way but can't sort using tab.
sort in fact *does* already consider tab characters as delimiters per default, but the locale setting can override this ... as denoted in the Texinfo pages: `-t SEPARATOR' `--field-separator=SEPARATOR' Use character SEPARATOR as the field separator when finding the sort keys in each line. By default, fields are separated by the empty string between a non-blank character and a blank character. By default a blank is a space or a tab, but the `LC_CTYPE' locale can change this. BTW: the locale settings are the biggest cause of confusion/surprise when sort's behavior is discussed in upstream mailing lists. Therefore, already an FAQ entry exists (see b in the following list). In general, there are 3 good advices for questions about using sort: a) read the texinfo manual (with tools like 'info' or 'pinfo'): $ info coreutils 'sort invocation' b) there is an FAQ entry, please read it: http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Sort-does-not-s... c) use the --debug option to get a hint how 'sort' processes your input (it will even give you hints): $ printf "%s\n" $'a\t2' $'a\t1' | sort --debug -k2,2n -k1,1 sort: using ‘en_US.UTF-8’ sorting rules sort: leading blanks are significant in key 2; consider also specifying 'b' a>1 _ _ ___ a>2 _ _ ___ Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (4)
-
Anton Aylward
-
Bernhard Voelker
-
Dirk Gently
-
Joe Zien