AWK output to bash Array AWK output to bash Array bash bash

AWK output to bash Array


You need to reset the IFS variable (the delimeter used for arrays).

OIFS=$IFS #save originalIFS=','df -h | awk '{ print $5" "$6"," }'


You could do this in Bash without awk.

array=()while read -a line; do    array+=("${line[4]} ${line[5]}")done < <(df -h)


You may use this:

eval array=( $(df -h | awk '{ printf("\"%s %s\" ", $5, $6) }') )