bash - 如何从文件中包含 whiptail 的数据?

标签 bash

如何使用输入文件 file.data 配置 whiptail 对话框?

whiptail --menu "foo" 0 0 0 2>/tmp/out

file.data的内容:

"01" "Item 1"
"02" "Item 2"
"03" "Item 3"
"04" "Item 5"

dialog 支持 --file 选项:

 dialog --file /tmp/file.data

但是 whiptail 没有。有没有类似的东西?

最佳答案

我认为您需要手动构建参数列表。

menu_options=()
while read -r number text; do
    menu_options+=( ${number//\"} "${text//\"}" )
done < file.data

whiptail --menu "foo" 0 0 0 "${menu_options[@]}" 2>/tmp/out

关于bash - 如何从文件中包含 whiptail 的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15229986/

相关文章:

在脚本开始时输入的 linux bash 脚本

linux - 值是否在 bash shell 的范围内

bash - 从bash脚本运行docker的奇怪行为

bash - awk 或 sed 帮助修改 CSV 或 TSV 文件的第一行

linux - 使用shell脚本删除文件夹内容

linux - docker镜像的环境变量写在哪里?

linux - 我怎样才能得到实时值来特别在 BASH 中制作我自己的脚本,如附件所示

linux - 命令显示正确,但随后执行不同

linux - 如何从 Bash 中的数组中获取唯一值?

linux - 将源代码与包含 sudo 命令的脚本一起使用