Pregunta

Quiero un poco de ayuda con mi guión. Quiero ejecutar algunos comandos dentro de la lista de zenity. Aquí está mi código

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
)

Mi problema es que no funciona si es Declaración. Que quiero es si $ cheques es 0, luego continúe sin ejecutar ningún comando.Si el resultado es 1 o más grande, entonces runnig Algunos comandos. Cualquier ayuda aceptada.

¿Fue útil?

Solución

en lugar de

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

Usted puede simplemente hacer:

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top