I) Liste des fichiers ordinaires d’une arborescence
En utilisant la commande find et awk , écrire une fonction qui listera certaines caractéristiques des fichiers d’une arborescence passée comme argument ( le nom du répertoire).
La syntaxe de la fonction doit être comme suit :
f-liste_fichiers répertoire
répertoire : le nom de l’arborescence à exploiter.
Si répertoire est omis, c’est le répertoire de connexion qui doit être pris comme argument par défaut.
Le résultat doit être trié sur le nombre de jours depuis la dernière date de modification.
Le résultat du script shell doit être comme suit :
Exemple de résultat à obtenir.
Liste des fichiers
-----------------------------------------------------------------------------------
| Nom |Taille(octets)|Modif. (js)|Accès (js) |
-----------------------------------------------------------------------------------
|/root/tp-unix/s2/tp01/cherche.txt | 0| 0| 0|
|/root/tp-unix/s1/tp02/extract.bash | 48| 39| 0|
|/root/tp-unix/s2/tp01/trouve | 114| 0| 0|
|/root/tp-unix/s2/tp01/p-awk04 | 156| 0| 0|
|/root/tp-unix/s2/tp01/p-awk05 | 213| 0| 0|
|/root/tp-unix/s1/tp02/prog01 | 257| 38| 9|
|/root/tp-unix/s1/tp02/p-awk01 | 261| 38| 9|
|/root/tp-unix/s2/tp01/p-awk01 | 318| 0| 0|
|/root/tp-unix/s2/tp01/p-liste_grande_lig | 480| 0| 0|
|ne | | | |
|/root/tp-unix/s2/tp01/p-liste_mots | 514| 0| 0|
|/root/tp-unix/s2/tp01/cherche | 545| 0| 0|
|/root/tp-unix/s2/tp01/p-awk03 | 103| 0| 0|
|/root/tp-unix/s2/tp01/p-awk02 | 1113| 0| 0|
|/root/tp-unix/s2/tp01/proc02 | 1150| 210| 0|
|/root/tp-unix/s2/tp01/proc01 | 2187| 203| 0|
|/root/tp-unix/s2/tp02.tar.gz | 155334| 30| 9|
|/root/tp-unix/s2/tp01/germinal.txt | 1008709| 0| 0|
-----------------------------------------------------------------------------------
Récapitulatif
Nombre de Fichier = 17
Espace Globale = 1172502 Octets 1145 K.octets 1 M.octets
Remarque : Si le nom du fichier dépasse la taille de la colonne, l’éclater en plusieurs lignes.
*********************************************************
*************************************************************
Écrire un programme awk : p-liste_mots.awk , qui comptera les mots en fonction de la taille des mots.
Le résultat doit être comme suit :
Comptage des mots
-----------------------------------------
| Taille du mot | Nombre de mots |
------------------------------------------
| 4 | 21841 |
| 5 | 19642 |
| 6 | 16995 |
| 7 | 14580 |
| 8 | 9513 |
| 9 | 7363 |
| 10 | 3959 |
| 11 | 2005 |
| 12 | 1051 |
| 13 | 463 |
| 14 | 213 |
| 15 | 74 |
| 16 | 21 |
| 17 | 3 |
| 19 | 3 |
-----------------------------------------

