简体   繁体   English

我如何按字母顺序循环浏览某些文件夹

[英]how do i loop through folders alphabetically up to certain folders

I am new to shell so please pardon me with my pseudocode below. 我是shell的新手,所以请用下面的伪代码原谅我。 Is there any in-built method in shell that could help me iterate up to certain folders i..e [A-M0-9] shell中是否有任何内置方法可以帮助我迭代某些文件夹,即[A-M0-9]

first i want to cd into the parent directory that consists of folders name starting from AZ then once i am in the parent folder i want to sort the parent directory alphabetically and then iterate through sub-directories from [A-M0-9]. 首先,我想进入包含由AZ开始的文件夹名称的父目录,然后一旦我进入父文件夹,我想按字母顺序对父目录进行排序,然后遍历[A-M0-9]中的子目录。

Below would the pseudocode of something what i am trying to attempt - 下面是我想要尝试的东西的伪代码-

cd /temp/parentDir

for f in [A-M0-9]
do
echo $f
done

You're actually really close. 你真的很亲密。 All you need is a wildcard: 您只需要一个通配符:

for f in [A-M0-9]*; do
    echo $f
done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM