I have requirement where first "n" rows ("n" being variable passed at run time) should be stored in "n" corresponding arrays, array name being named as arrayRow"NR"; here, NR is the built-in awk variable.
awk -F"," -v n=$Header_Count 'NR<=n{
split($0,**("arrayRow" NR)**) }' SampleText.txt
So the first row should be stored in array arrayRow1; the second row should be stored in arrayRow2, ... etc. Any ideas on how to create dynamic array name in awk?
You can't do it without a hacky shell loop and bad coding practices for letting shell variables expand to become part of an awk command, or a function that populates hard-coded, predefined arrays given a numeric arg or similar. Don't even try it.
If you have or can get GNU awk you should use true multi-dimensional arrays instead:
Otherwise you can use pseudo-multi-dimensional arrays in any awk:
but you don't actually need multi-dimensional arrays for this at all, just use 1-dimensional and split the string into a new array when you need it: