I want to get a part in every line of a regular file. For this purpose I've used the program awk in my script. I need to put each part in an array. Something like this works:
declare -i j=1
awk 'BEGIN { FS="|" } { a[j]=$6; ((j++)) }' myFile
but I have a problem after in the script, when I need to use the array. Indeed the array in the awk block isn't seen by the remaining lines of the script -- the lines outside that block. How can this problem be solved?
jinside and outside of the awk script refer to two different things.((j++))works inawktoo, there's no reason for enclosing the expression in parentheses (unlike inbash).