I have four files (file_one
to file_four
), the contents of these files isn't really important. I want to pass three of these files to a command (i.e. paste
or awk
) in a particular order as defined by an array.
My array is order=(two one four)
.
I was hoping to use the array to pass the desired files to the command as input similarly as how you could use *
(i.e. paste file_* > combined_file
);
paste file_${order[@]} > combined_file
paste file_"${order[@]}" > combined_file
paste file_"${order[*]}" > combined_file
paste file_"{${order[@]}}" > combined_file
paste file_{"${order[@]}"} > combined_file
I have looked at different pages (1, 2, 3 or 4) but I can't get it to to work. A loop
through the files doesn't work in the case of paste
or awk
. I want to pass the files all at once to a command. Seeing as my UNIX
knowledge is limited I may have misinterpreted some solutions/answers. From what I understand from this answer there might be some issues with how arrays were originally developed in bash
.
Desired result:
paste file_two file_one file_four > combined_file