I want to save some blkid output blkid in an array. The problem is that these lines contain spaces, and the array syntax accepts them as separators for individual elements of the array, so I get broken lines in my array, and not one line having one array element.
This is the code I have: devices=($(sudo blkid | egrep '^/dev/sd[bz]'))
echo ${devices[*]} gives me the following result:
/dev/sdb1: LABEL="ARCH_201108" TYPE="udf" /dev/sdc1: LABEL="WD" UUID="414ECD7B314A557F" TYPE="ntfs"
But echo ${#devices[*]} gives me 7 , but insted I want to have 2 . I want /dev/sdb1: LABEL="ARCH_201108" TYPE="udf" be the first element in my device array, and /dev/sdc1: LABEL="WD" UUID="414ECD7B314A557F" TYPE="ntfs" - second . How can i do this?
source share