J'ai un fichier texte qui ressemble à
text_a_3 xxx yyy
- - - - - - - - - - -
text_b_2 xyx zyz
- - - - - - - - - - -
text_b_3 xxy zyy
- - - - - - - - - - -
text_a_2 foo bar
- - - - - - - - - - -
text_a_1 foo bla
- - - - - - - - - - -
text_b_1 bla bla
Je veux trier ce fichier numériquement, en fonction du premier champ, de sorte que ma sortie ressemble à:
text_a_1 foo bla
- - - - - - - - - - -
text_a_2 foo bar
- - - - - - - - - - -
text_a_3 xxx yyy
- - - - - - - - - - -
text_b_1 bla bla
- - - - - - - - - - -
text_b_2 xyx zyz
- - - - - - - - - - -
text_b_3 xxy zyy
Je pensais que sort ferait l'affaire. J'ai donc essayé
sort -n nom_de_mon_fichier
sort -k1 -n nom_de_mon_fichier
Mais cela donne
- - - - - - - - - - -
- - - - - - - - - -