问题
for i in $(seq 1 10); do
echo 'bla bla'
echo 'xxx'
echo $i
done | select=$(zenity --list --title="title" --text="text" --column="X" --column="Y" --column="Z");
I try to create a checklist with zenity, my problem is that $select is always empty. I try to do it in few other ways, like this one:
for i in $(seq 1 10)
do
x="bla bla"
y="xxx"
z="$i"
table="$table '$x' '$y' '$z'"
done
eval zenity --list --title="title" --text="text" --column="X" --column="Y" --column="Z" $table
In this way the $select variable isn't empty but if there are spaces in some variable (like $x for example) zenity split it to 2 (or more) columns.
I need other solution or any fix for my code(s)?
Thanks!
回答1:
You can try this other approach:
#!/bin/bash
for i in $(seq 1 10)
do
echo "bla bla"
echo "xxx"
echo "$i"
done | zenity --list --title="title" --text="text" --column="X" --column="Y" --column="Z"
Each line populate the table from the first column to the last, and then again on a new row, until the input stream ends.
来源:https://stackoverflow.com/questions/4706029/zenity-list-and-for-loop