sort (Unix)
Outils
Général
Imprimer / exporter
Dans d’autres projets
Pour les articles homonymes, voirsort.
sort est une commandePOSIX qui permet detrier des fichiers ou leurs contenus.
Par défaut,sort affiche l'ensemble des lignes des fichiers qu'on lui passe en paramètre triées par ordre croissant de la table de codage des caractères (par exempleASCII).
%catfichier1.txtligne1ligne1_fichier1ligne2ligne2_fichier1%catfichier2.txtligne1ligne1_fichier2ligne2ligne2_fichier2%sortfichier2.txtfichier1.txtligne1ligne1_fichier1ligne1ligne1_fichier2ligne2ligne2_fichier1ligne2ligne2_fichier2
Il est possible de s'en servir pour trier des fichiers par types et tailles :
$ls-al-rwxr-xr-x1rootroot50002010-05-1617:00fichier1-rwxr-xr-x1rootroot1002010-05-1717:00fichier2drwxr-xr-x3rootroot40962010-05-1617:00répertoire1drwxr-xr-x3rootroot40962010-05-1717:00répertoire2$ls-al|sort-ndrwxr-xr-x3rootroot40962010-05-1617:00répertoire1drwxr-xr-x3rootroot40962010-05-1717:00répertoire2-rwxr-xr-x1rootroot1002010-05-1717:00fichier2-rwxr-xr-x1rootroot50002010-05-1617:00fichier1$ls-al|sort+4n-rwxr-xr-x1rootroot1002010-05-1717:00fichier2drwxr-xr-x3rootroot40962010-05-1617:00répertoire1drwxr-xr-x3rootroot40962010-05-1717:00répertoire2-rwxr-xr-x1rootroot50002010-05-1617:00fichier1
| Aide | ||
|---|---|---|
| Environnementutilisateur | ||
| Gestion deprocessus | ||
| Manipulation detexte | ||
| Programmationshell | ||
| Recherche | ||
| Réseau | ||
| Système de fichiers | ||
| Divers | ||