Enumérer les types de fichiers sous Linux et Unix

La version ligne de commande :

  1. find . -print|xargs file|awk ‘{$1= »";x[$0]++;}END{for(y in x)printf(« %d\t%s\n« ,x[y],y);}’|sort -nr

La version script :

  1. #!/bin/sh
  2. find . -print | xargs file |
  3. awk ‘{
  4. $1= »";
  5. x[$0]++;
  6. }
  7. END {
  8. for (y in x) printf(« %d\t%s\n« , x[y], y);
  9. }’ | sort -nr
Ce qui aura pour effet d’afficher sur la console quelques chose comme ça :
9025     gzip (.gz) compressed data
2235     ascii text
2080     empty
16       directory
6        shell script – ksh (Korn shell)
3        data or International Language text
2        shell script – sh (default shell)
1        tar archive
1        compressed data block compressed 16 bit
1        c program text
1        PKZIP (.zip) compressed archive

Posts relatifs

Laisser un commentaire


NOTE - Vous pouvez utiliser les éléments et attributs HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>