Hi experts,
I have been trying for a while to accomplish the following task using awk, and I just don't seem find find a way. I am not particular about using awk, it just seemed like the logical choice at first.
I have a file that contains 5 fields that are delimited by a space character. These fields are options and I need to change either one or more of them.
The new options are read in from standard input, i.e. the user provides a new set of options.
so, I read in the options and then I have a file and for each line in the file I aks the user if he wants to change particular options (they refer to locations).
But I don't seem to manage to read from the array.
as an example:
text file:
one two three four five
here there somewhere anywhere nowhere
sometimes options may contain only one field, sometimes they contain 2 or more and I want to replace items starting at the 3rd field.
so that afterwards, if options are
options=(this that)
the text file would look like
one two this that five
here there this that nowhere
how can this be achieved???
or if options=(this)
the text file would look like:
one two this four five
here there this anywhere nowhere
This decision is made dynamically, depending on how many options the user provides, but always starts at $3.
Anyone any ideas??