Probleme shell

christophe1371 -  
 chrisotphe1371 -
Bonjour,
j'aimerai récuperer dans un tableau la liste des fichiers communs a deux répertoires en shell

merci
Configuration: Windows XP
Firefox 2.0.0.7

2 réponses

  1. jipicy Messages postés 40842 Date d'inscription   Statut Modérateur Dernière intervention   4 898
     
    Salut,

    Une façon de faire :
    [tmpfs]$ tree
    .
    |-- rep1
    |   |-- fich1
    |   |-- fich2
    |   |-- fich3
    |   |-- tata
    |   |-- titi
    |   `-- toto
    `-- rep2
        |-- fich1
        |-- fich2
        |-- fich3
        |-- mama
        |-- mimi
        `-- momo
    
    2 directories, 12 files
    
    [tmpfs]$ ls rep1/ rep2/ | sort | uniq -d > plop
    
    [tmpfs]$ cat plop
    
    fich1
    fich2
    fich3
    
    [tmpfs]$ tableau=( $(cat plop) )
    
    [tmpfs]$ echo ${#tableau[@]}
    
    3
    
    [tmpfs]$ echo ${tableau[@]}
    
    fich1 fich2 fich3
    
    [tmpfs]$ echo ${tableau[0]}
    
    fich1
    
    [tmpfs]$ echo ${tableau[1]}
    
    fich2
    
    [tmpfs]$ echo ${tableau[2]}
    
    fich3
    
    [tmpfs]$ 
    ;-))
    0