문제

나는 내 스크립트에 약간의 도움을 원한다. Zenity 목록에서 일부 명령을 실행하고 싶습니다. 다음은 내 코드

입니다
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
)
.

내 문제는 다른 것이 명령문을 작동하지 않는 것입니다. 내가 원하는 것은 $ check 결과가 0이면 모든 명령을 실행하지 않고 계속 진행하십시오.결과가 1이면 1이면 일부 명령이 runnig 명령됩니다. 어떤 도움이 허용됩니다.

도움이 되었습니까?

해결책

대신

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

할 수 있습니다 :

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top