BASH Script - Liste de Zenity avec la déclaration IF
-
26-12-2019 - |
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
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