Como ordenar para que caml seja depois de c em um xml?

0

Classificando um arquivo com linhas

<LexerType name="caml" desc="Caml" ext="">
<LexerType name="c" desc="C" ext="">

faz com que caml seja antes de c, como eu coloco c primeiro em geral, sem depender das posições dos caracteres deste arquivo?

    
por nnn 23.12.2011 / 22:15

1 resposta

0

usando sort

$ sort -t\" -k2,2 file.xml
<LexerType name="c" desc="C" ext=""/>
<LexerType name="caml" desc="Caml" ext=""/>
   -k, --key=POS1[,POS2]
          start a key at POS1, end it at POS2 (origin 1)
   -t, --field-separator=SEP
          use SEP instead of non-blank to blank transition

usando vim

:%sort /name=/

ou

:%sort r /name="\w*"/
:[range]sor[t][!] [i][u][r][n][x][o] [/{pattern}/]

                    When /{pattern}/ is specified and there is no [r] flag
                    the text matched with {pattern} is skipped, so that
                    you sort on what comes after the match.
                    Instead of the slash any non-letter can be used.
                    For example, to sort on the second comma-separated
                    field: >
                            :sort /[^,]*,/
                    To sort on the text at virtual column 10 (thus
                    ignoring the difference between tabs and spaces): >
                            :sort /.*\%10v/
                    To sort on the first number in the line, no matter
                    what is in front of it: >
                            :sort /.*\ze\d/

                    With [r] sorting is done on the matching {pattern}
                    instead of skipping past it as described above.
                    For example, to sort on only the first three letters
                    of each line: >
                            :sort /\a\a\a/ r
    
por 24.12.2011 / 06:22

Tags