Redirection commande wc
Bonjour,
jaimerais rediriger la commande wc -l.
Je fais donc
Mais dans le fichier de sortie j'obtiens : "2 gen.txt"
Comment faire pour obtenir que le "2" ?
Merci
jaimerais rediriger la commande wc -l.
Je fais donc
wc -l gen.txt > tmp.txt
Mais dans le fichier de sortie j'obtiens : "2 gen.txt"
Comment faire pour obtenir que le "2" ?
Merci
2 réponses
-
ModérateurUtilise un filtre cut.
Par exemple:johand@osiris: ~/tmp $ wc -l formulaire.html | cut -d " " -f1 > tmp.txt johand@osiris: ~/tmp $ cat tmp.txt 106
Si tu veux récupérer la valeur dans une variable (sous bash)
nombre_de_lignes=$( wc -l formulaire.html | cut -d " " -f1)
echo $nombre_de_lignes
Voir: man cut
Gates gave ^H sold you the windows.
GNU gave us the whole house.(Alexandrin) -
Contributeurhello
comme ça:wc -l < gen.txt > tmp.txt