Я пытаюсь сделать функцию удаления внутри окна ввода Zenity. Я хотел бы знать, как я могу хранить путь, данный пользователем внутри ввода в переменную или как я могу использовать его. Спасибо вот мой код
#!/bin/bash
function Ddate() {
zenity --info \
--title "Date and Time" \
--text "Today is $(date)"
}
function Dcalendar() {
zenity --calendar \
--title "Calendar" \
}
function Ddelete() {
zenity --entry \
--entry-text "Ex: home/knoppix/" \
--text "Enter a path" \
--title "Delete" \
}
while true;
do
choice="$(zenity --height 275 --width 450 \
--list \
--title="Menu" \
--column="Function" --column="Description" \
Date 'Display the actual date and time.' \
Calendar 'Display an interactive calendar.' \
Delete 'Let you delete a file.' \
Exit 'To quit this script.')"
case $choice in
Date) Ddate;;
Calendar) Dcalendar;;
Delete) Ddelete;;
Exit) break;;
esac
done
Обычно, если вы хотите вставить данные в переменной из «Zenity», вы можете попробовать этот пример:
NAME=$( zenity --entry --text="type your name" )
if [ $? = 0 ] # check if the user click ok on the zenity form
then
echo "Hello $NAME"
else
echo "the user didn't click ok button"
fi
Я надеюсь, что это поможет.