我正在尝试写类似以下内容
for i in {a..z} && j in {1..26}
do
echo "/dev/sd"$i"1 /disk$j ext4 noatime 1 1" >> test
done
当然,这不是正确的语法。有人可以帮助我使用正确的语法来执行此操作吗?
为了通用,您可以使用“长度”,如下所示。
#!/bin/bash
# Define the arrays
array1=("a" "b" "c" "d")
array2=("w" "x" "y" "z")
# get the length of the arrays
length=${#array1[@]}
# do the loop
for ((i=0;i<=$length;i++)); do
echo -e "${array1[$i]} : ${array2[$i]}"
done
您还可以像下面这样分配数组
array1=`awk -F" " '$1 == "CLIENT" { print $2 }' clientserver.lst`
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)