Question

Je veux un peu d'aide avec mon script. Je veux exécuter des commandes à l'intérieur de la liste de zénity. Voici mon code

check=$(cat file.txt | grep -c "word")
opt1=$(coomand..)
opt2=$(command..)
opt3=$(command..)

respo=$(zenity  --list  --checklist  --column "Choose" --column "" FALSE "$opt1" FALSE "$opt2" FALSE "$opt3"   --separator=":")
(
[[ $respo = $opt1 ]] && command
[[ $respo = $opt2 ]] && command
[[ $respo = $opt3 ]] && command

if [ $check = "0" ] ; then
:
else
command 1
command 2
command 3
command 4
command 5
command 6
fi
)

Mon problème est que cela ne fonctionne pas si sinon déclaration. Que je veux, c'est si $ check résultat est 0 puis continuez sans exécuter aucune commande.Si le résultat est 1 ou plus, puis runnig certaines commandes. Toute aide acceptée.

Était-ce utile?

La solution

au lieu de

check=$(cat file.txt | grep -c "word")
if [ $check = "0" ] ; then

Vous pouvez simplement faire:

if ! grep -q "word" file.txt; then

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top