|
|
|
|
Pour avoir la ligne X (=nombre comme 1,2,3, ...) tu peux faire:
|
Salut,
var=`head -$nu_ligne $fichier | tail -1` Ou alors awk pour les fichiers plus gros
var=`awk -v l=$nu_ligne 'NR==l{ print }' $fichier`
Bien sur nu_ligne est la variable contenant le numéro de ligne, fichier le chemin d'accès au fichier. A+ Besides, I think Slackware sounds better than 'Microsoft,' -- Patrick Volkerding |
Salut,
[jp@Mandrake scripts]$ cat fich nom_fichier_1 ; commentaire associé au fichier 1 nom_fichier_2 ; commentaire associé au fichier 2 nom_fichier_4 ; commentaire associé au fichier 4 nom_fichier_5 ; commentaire associé au fichier 5 nom_fichier_7 ; commentaire associé au fichier 7 nom_fichier_9 ; commentaire associé au fichier 9 nom_fichier_10 ; commentaire associé au fichier 10 nom_fichier_12 ; commentaire associé au fichier 12 nom_fichier_14 ; commentaire associé au fichier 14 nom_fichier_15 ; commentaire associé au fichier 15 nom_fichier_16 ; commentaire associé au fichier 16 Pour extraire la 3 ème ligne [jp@Mandrake scripts]$ sed -n 3p fich nom_fichier_4 ; commentaire associé au fichier 4 La 5 ème : [jp@Mandrake scripts]$ sed -n 5p fich nom_fichier_7 ; commentaire associé au fichier 7 Pour la récupérer dans une variable : [jp@Mandrake scripts]$ var=`sed -n 5p fich` [jp@Mandrake scripts]$ echo $var nom_fichier_7 ; commentaire associé au fichier 7 [jp@Mandrake scripts]$;-)) Z'@+...che. JP : Zen, my Nuggets ! ;-) Le savoir n'est bon que s'il est partagé. |