I am trying to write something like following
for i in {a..z} && j in {1..26}
do
echo "/dev/sd"$i"1 /disk$j ext4 noatime 1 1" >> test
done
Of course this is not correct syntax. Can someone please help me with correct syntax for doing this?
To be generic, you can use 'length' as shown below.
#!/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
You can also assign the array like the following
array1=`awk -F" " '$1 == "CLIENT" { print $2 }' clientserver.lst`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With