如何编写特定组的输出命令?

如何编写特定组的输出命令?
Reading file prod1.tpr, VERSION 2019.6 (single precision)
Reading file prod1.tpr, VERSION 2019.6 (single precision)
Select a group of reference atoms and a group of molecules to be ordered:
Group     0 (         System) has 56000 elements
Group     1 (          Other) has 56000 elements
Group     2 (           DPPC) has 26000 elements
Group     3 (           TIP3) has 30000 elements
Group     4 (     Up_Choline) has  2000 elements
Group     5 (    Low_Choline) has  2000 elements
Group     6 (         Up_PO4) has   500 elements
Group     7 (        Low_PO4) has   500 elements
Group     8 (    Up_Glycerol) has  1100 elements
Group     9 (   Low_Glycerol) has  1100 elements
Select a group:

是否可以为 shell 脚本内的特定组提供输入,因此无需在终端中为特定组选择数字?如果是,那么在 shell 脚本中选择特定组的格式是什么?

答案1

假设该命令从标准输入中读取用户输入,那么只需通过管道发送您想要提供的输入即可,例如:

echo 4 | your-command

因此,您的命令4<newline>将从其标准输入中读取,这是管道的读取端。/dev/pts/<n>如果您从终端运行并输入 ,这与从某个文件中读取的 2 个字符相同4Enter

相关内容