In the above array, how can I print to screen just the first 8 elements of ${PH[@]} and have the last 2 elements print just below the first line starting underneath AD?
I need to do this in order to save terminal window spacing for Bash Script.
While this happens to work with the sample array provided, asking to print 9 elements starting with index 8 seems to be a strange way to print the last two elements of an array of 10 elements. If you want to print the 1st 7 elements of an array on one line and the last 2 elements of that array on a second line (no matter how many elements are in the array, you might want to try something more like:
or, if there is any chance that any of those elements in your array might contain multiple adjacent spaces, might contain tabs, or might contain newlines that you want preserved in the output:
cogiz, I noticed that your final solution was to limit to 24 fields. 24 %s s are a lot to type but I think it will be the most practical solution to your problem.