linux - 自动从选项列表中选择选项,无需输入值

标签 linux unix

命令是“source meta-cmf-raspberrypi/setup-environment”。运行此命令后,它为我提供了一个环境列表,之后用户应该给出一个整数值。一旦给出输入,就会选择所需的环境。我想自动执行此命令,因为所选环境选项始终保持不变。

例如:假设当我运行此命令时,我会得到如下列表:

subhro@Subhro-ThinkCentre-M79:~/Desktop/rdkb_workspace$ source meta-cmf-raspberrypi/setup-environment
 1) meta-cmf-bsp-emulator/conf/machine/qemux86broadbanddev.conf
 2) meta-cmf-bsp-emulator/conf/machine/qemux86hybdev.conf
 3) meta-cmf-raspberrypi/conf/machine/raspberrypi3-64-rdk-broadband.conf
 4) meta-cmf-raspberrypi/conf/machine/raspberrypi-rdk-broadband.conf
 5) meta-cmf-raspberrypi/conf/machine/raspberrypi-rdk-broadband-musl.conf
 6) meta-cmf-raspberrypi/conf/machine/raspberrypi-rdk-hybrid.conf
 7) meta-cmf-raspberrypi/conf/machine/raspberrypi-rdk-hybrid-westeros.conf
 8) meta-cmf-raspberrypi/conf/machine/raspberrypi-rdk-mc.conf
 9) meta-cmf-raspberrypi/conf/machine/raspberrypi-rdk-mc-westeros.conf
10) meta-raspberrypi/conf/machine/raspberrypi0.conf
11) meta-raspberrypi/conf/machine/raspberrypi2.conf
12) meta-raspberrypi/conf/machine/raspberrypi3-64.conf
13) meta-raspberrypi/conf/machine/raspberrypi3.conf
14) meta-raspberrypi/conf/machine/raspberrypi.conf
15) meta-rdk-bsp-emulator/conf/machine/qemuarmbroadband.conf
16) meta-rdk-bsp-emulator/conf/machine/qemux86broadband.conf
17) meta-rdk-bsp-emulator/conf/machine/qemux86hyb.conf
18) meta-rdk-bsp-emulator/conf/machine/qemux86hyb-morty.conf
19) meta-rdk-bsp-emulator/conf/machine/qemux86mc.conf
20) meta-rdk-bsp-emulator/conf/machine/qemux86mc-morty.conf
21) openembedded-core/meta/conf/machine/qemuarm64.conf
22) openembedded-core/meta/conf/machine/qemuarm.conf
23) openembedded-core/meta/conf/machine/qemux86-64.conf
24) openembedded-core/meta/conf/machine/qemux86.conf
25) openembedded-core/meta-selftest/conf/machine/qemux86copy.conf
Please enter your choice of machine [1..25]: 

我想运行一个命令,以便它自动选择该选项。我尝试过使用 "echo" 并使用源 meta-cmf 命令管道化命令,它有效。但我正在寻找其他东西。

最佳答案

在调用设置环境脚本之前,您只需将 MACHINE 环境变量设置为您想要构建的机器:

示例:

MACHINE="raspberrypi4-64" source meta-cmf-raspberrypi/setup-environment

关于linux - 自动从选项列表中选择选项,无需输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57489081/

相关文章:

linux - 有人可以帮助修复我的 vimrc 配置吗?

linux - 使用 awk 按列数将行移动到文件中

linux - Kafka 服务器在按 CTRL+c 时出现故障

python - sqlite3 3.5.7 与 3.6.21 括号问题

unix - 带有 Apache Directory 和 RewriteRule 的通配符?

java - ProcessBuilder 不使用通配符执行命令

c++ - Ubuntu 上的 Google Earth C++ API 库错误

c - STDIN_FILENO 和 STDOUT_FILENO 在 c 中只读吗?

ios - 在 ios 应用程序中加载 unix 可执行文件

unix - grep UNIX 中的一个选项卡