I have a file of patterns (fileA.txt) which need to be searched in a large file (fileB.txt) and they need to be replaced with patterns in another file (fileC.txt) Example:
fileB.txt
4472534
8BC4232
3533221
333553D
8645141
2412AAA
I want to search this patterns in fileB:
fileA.txt
BC423
33221
12AAA
Then I want to replace them with patterns in fileC, line by line:
fileC.txt
66FF7
11GYT
2HHJK
Expected output:
4472534
866FF72
3511GYT
333553D
8645141
242HHJK
I wrote something like this:
grep -f fileA.txt fileB.txt | xargs sed -i fileC.txt
however, it searches correctly the patterns but the substitution is probably not correct. Any advice?
fileA (pattern to search)
CAAGATTTTCTTTGCCGAGACTCAGTGGGG
fileB
>AMP_4 RS0255 CENPF__ENST00000366955.7__6322__30__0.43333__69.25__1 RS0247
CAGTTGTGCAATTTGGTTTTCCAGCTCACA
>AMP_4 RS0451 CENPF__ENST00000366955.7__10108__30__0.5__71.1396__1 RS0247
GAAGCCTGCAGCCCTCACTGGAAATAAACA
>AMP_4 RS0451 CENPF__ENST00000366955.7__9236__30__0.5__69.816__1 RS0332
CAAGATTTTCTTTGCCGAGACTCAGTGGGG
>AMP_4 RS0451 CENPF__ENST00000366955.7__8140__30__0.43333__68.033__1RS0255
GAGCTCCTTCAATTGATCTTTGCTGCTCTT
fileC (pattern to replace)
GGAGGATGGTGCCTGAATCTACTGGGCTCC