grep ne semble pas vouloir prendre en compte une variable
bonjour ts,
j'ai écrit ce petit programme en bash
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| #!/bin/bash
sudo chmod 777 /home/access/dossiertst/suppr.txt
sudo chmod 777 /home/access/dossiertst/tstinfo.txt
sudo chmod 777 /home/access/dossiertst/tstlogin.txt
exist=`ls -l | grep 'suppr.txt' | wc -l`
if [ $exist -eq 1 ]
then
if [ $exist = 1 ]
then
read nom<suppr.txt
exist2=`cat /home/access/dossiertst/tstlogin.txt | grep $nom | wc -l`
if [ $exist2 = 1 ]
then
# Recuperation du MP 2eme champs du fichier info
password=`cat tstinfo.txt | grep $nom | cut -f 2 -d':'`
# effacer les entree en question dans le fichier login
sudo sed '/$nom/d' /home/access/dossiertst/tstlogin.txt
sudo sed '/$password/d' /home/access/dossiertst/tstlogin.txt
#cat login_bkp | grep -v $nom> login.txt
#rm -f login_bkp
fi
# sudo rm -f suppr.txt
sudo chmod 600 /home/access/dossiertst/suppr.txt
sudo chmod 600 /home/access/dossiertst/tstinfo.txt
sudo chmod 600 /home/access/dossiertst/tstlogin.txt
fi
fi |
la commande GREP déconne dans les deux cas, le fait de recevoir une variable $nom ne l'accepte pas je vois pas pour quoi:cry:
merci pour votre aide