I'm trying to determine the existing HDDs in each system using a for loop as show below, the problem is when I try to set the variable using the below code i get sda=true: command not found. What is the proper way to do this?
#!/bin/bash
for i in a b c d e f
do
grep -q sd$i /proc/partitions
if [ $? == 0 ]
then
sd$i=true
else
sd$i=false
fi
done
declare sd$i=trueSo there is one catch I have found with this. When I use this in a function, the variable is null outside of the function. How do I get around this?exportin this case. (I have updated my answer.)