sed to replace specific positions on line with file contents

Hi, I am trying to use an awk command to replace specific character positions on a line beginning with 80 with contents of another file.

The line beginning with 80 in file1 is as follows:

I want to replace the 000000000178800 (positions 34 - 49) on this file with the contents of amended_file_01 -> 000000000206100

The command i am using is:

The output from this command should be

But it is returning the filename instead of the file contents

How would i get the command to return the file contents instead of the filename?

I hope you have code to store the contents of file "amended_file_01" into variable "amended_file01"; after which a minor adjustment to your sed one-liner should do the trick:

sed "/^80/s/\(^.\{34\}\).\{15\}\(.*\)/\1$amended_file01\2/" file1
1 Like

Hi balajesuri,

That's perfect, thanks for your help