Awk split use array later in bash -
if have awk command...
echo $line | awk '{split($0,array,"|")}'
...how can use array later in bash program? if try print out information array later it's empty.
you can use awk
array contents outside of awk
if print it:
ifs=$'\n' read -d '' -r -a line < <(echo 'o|p|s' | awk '{split($0,array,"|"); (i in array) print array[i]}') declare -p line # output: declare -a line='([0]="o" [1]="p" [2]="s")'
Comments
Post a Comment