【问题标题】:How would I send the output of ls to a for loop that assigns arguments to a case statement?如何将 ls 的输出发送到将参数分配给 case 语句的 for 循环?
【发布时间】:2013-03-21 05:48:27
【问题描述】:

伪代码是

for OUTPUT in $(ls -d */)
do
case $OUTPUT in
1 ) $OUTPUT ;;
esac
done
*) echo -e "Oops!!! Please select a valid number";

不确定这是否可能或是否有意义?

【问题讨论】:

    标签: bash for-loop


    【解决方案1】:

    首先,不要解析ls。只需使用 glob:

    for OUTPUT in */
    

    其次,阅读bash 文档中有关select 命令的部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-30
      • 1970-01-01
      • 1970-01-01
      • 2020-01-21
      • 2019-05-10
      • 1970-01-01
      • 2012-06-08
      • 1970-01-01
      相关资源
      最近更新 更多