我无法找到一种正确表达自己的方式,因为如果我弄得一团糟,我会深感抱歉。
我的问题是: 如何在bash的for循环中使用字母a..z?
#Aim is to list commands are the directory /usr/bin
#!/bin/bash
cd /usr/bin
for i in {a..z}
array=($(ls --ignore=[!a]*)) #Just lists commands starting with "a"
echo ${array[@]}
----------------
#I tried to do a substitution in the below code, where may I be wrong?
#!/bin/bash
cd /usr/bin
for i in {a..z}
array=($(ls --ignore=[!$i]*))
echo ${array[@]}
答案 0 :(得分:0)
要循环 a 到 z ,请使用以下内容:
for x in {a..z}
do
echo "$x" # prints alphabet
done