Question: I have several file like `A_bla.csv`(i.e `B_bla.csv` `C_bla.csv` etc ...) (It's a subsampling of the real file in term of lign but the number of column is the real one) :

```
1,test,test2,55.2,test3
1,test,test2,96.3,test3
1,test,test2,64.2,test3
1,test,test2,97.2,test3

```

And a main file `main.tsv` (field separator = `\t`):

```
id  coverage    clade
A   wrongdata   20
B   wrongdata   19
C   wrongdata   19

```

And I want to print the field of the 89th line of the 4th column from each `*_bla.csv` file into the `coverage` column of `main.tsv` file. In order to do that, I need to use the FILENAME of the `*_bla.csv`file and use it as pattern with the `id` column of `main.tsv` file.

So far I tried :

```
for file in *_bla.csv ; do
r="$(basename -s "_bla.csv" $file)"
awk ... ; 
done

```

But I'm near to a start of answer. Do you have an idea how to do that using only tool that are by default in a Linux machine (awk,grep,sed,python,perl ...) ? Thanks

Answer: 
The unavoidable GNU `sed` one-liner:

```
sed '1n;h;s/\([[:alnum:]]\).*/sed -E "89!d;s_([^,]*,){3}__;s_,.*__" \1_bla.csv/e;G;s/\(.*\)\n\(.*\)wrongdata/\2\1/' main.tsv

```

What's the magic? We use the `e`xecute option to the `s`ubstitute command to extract the 4th field of the 89th line with another `sed` command. In detail:

* `1n` to leave the first line unchanged
* `h` to store the line in hold space before we mess it up
* `\([[:alnum:]]\).*` matches the whole line and captures the first alphanumeric field in `\(\)` so we can refer to it as `\1` in the replacement
* `sed -E "89!d;s_([^,]*,){3}__;s_,.*__" \1_bla.csv` is this replacement: All lines except for 89 will be `d`eleted, then the first three fields get deleted and finally everything after the new first field. So actually only the fourth field of line 89 survives, so this will be returned by the `e`xecution of the buffer
* Now we only need to append the save line from the hold space with `G` and use `s/\(.*\)\n\(.*\)wrongdata/\2\1/` to replace `wrongdata` with the extracted field.
```none
awk -F',|\t' '
FILENAME != "main.tsv" && FNR == 89 {
                        sub(/_.*$/, "", FILENAME)
                        A[FILENAME]=$4
                        }
FILENAME != "main.tsv"  {next}
A[$1]                   {$2 = A[$1]}
                        {print}
' *bla.csv OFS='\t' main.tsv

```

I see that there is no tab delimiter in the `main.tsv` file. Then it will be necessary to correct the pattern like this: `-F',|[[:blank:]]+'`