linux 从选项列表中自动选择选项而不输入值

sycxhyv7  于 2022-11-22  发布在  Linux
关注(0)|答案(2)|浏览(161)

这个命令是"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命令,它的工作。但我正在寻找其他东西。

n6lpvg4x

n6lpvg4x1#

在调用setup-environment脚本之前,您只需将MACHINE env变量设置为要为其构建的计算机:
示例:

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

cgfeq70w2#

这也是一种方法,应该适用于此。它选择9。选项。

source meta-cmf-raspberrypi/setup-environment <<EOF
9
EOF

相关问题