Your advice has fix one problem, but raised another. The variable $rec1_field, actually contains $1,$2,$3 etc, in other words it contains the format required to produce a desired result. When I use the -v option
awk -v awkvar=$new_rec1_field '{if ( NR != 1 ) { print $awkvar }}' $file1 >> combined
awk displays and error stating it can't parse $($1,$2,$3 etc
Instead of getting the field information printed, I get $1,$2,$3..... etc printed. That is variable $1 is not being replaced by the first field in the file $file1
What is your exact requirement? What does the variable new_rec1_field hold? If it is refering to fields -$1, $2 etc. why can't it be directly use inside awk?
I have written a script that combines several files that contains both similar and dissimilar fields within each record. The resultant file needs to be a concatenation of all files vertically, not horizontally (ie can't use cat). Can't use join as any common field can only be displayed once in the resultant file.
So I created a variable "$rec1_field" that contains the order of the variables I need to be output for each record, as parsed by awk.
The variable literally contains "$1,$2,$3,....". What I thought I could do ,is replace {print $1} within awk with {print $rec1_field}, and let awk expand the variable to $1,$2,etc.
I developed the script on a Linus Red Hat platform and it works 100%, but when I run it under AIX it fails. See previous posts.