在 Bash 中循环字母 [英] Looping through alphabets in Bash
本文介绍了在 Bash 中循环字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想mv
所有以'x'开头的文件到'x'目录;类似:
I want to mv
all the files starting with 'x' to directory 'x'; something like:
mv path1/x*.ext path2/x
并对所有字母 a, ..., z 执行此操作
and do it for all alphabet letters a, ..., z
我如何编写一个 bash 脚本来让 'x' 在字母表中循环?
How can I write a bash script which makes 'x' loops through the alphabet?
推荐答案
for x in {a..z}
do
echo "$x"
mkdir -p path2/${x}
mv path1/${x}*.ext path2/${x}
done
这篇关于在 Bash 中循环字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文