DL_OPS
is a single value, not an array. When you use array indexing with a non-array variable, index 0 is the value, other indexes are empty.
If you just wrap ()
around the call to awk
, it will split the output at any whitespacethe space characters, so each word will be a separate array element. You need to split it just at newlines, which you can do by setting IFS
.
You should also disable filename wildcard expansion, in case the file contains wildcards that happen to match filenames.
set -o noglob
IFS=$'\n' DL_OPS=($(awk -F "|" 'NR>1 {print $4}' input_file.txt))