bash script - zenity list with if statement

1.3k views Asked by At

I want a little help with my script. I want to run some commands inside zenity list. here is my 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
)

My problem is that doesn't work if else statement. That i want is if $check result is 0 then continue without running any command. If result is 1 or bigger then runnig some commands. Any help accepted.

1

There are 1 answers

2
anubhava On BEST ANSWER

Instead of

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

You can just do:

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