How can I use bash to replace a string in a file from another file For example:
There is a path: \\Hostname\example\example.txt
I want to replace the Hostname
with 162 hostnames from another file that contains the 162 hostnames then I save the result.
So the total path should be : 162 paths with different hostnames (162)
The first folder is : Paths.txt ( has 2 paths):
\\Hostname\example1\example1.txt
\\Hostname\example2\example2.txt
The Second file is: Hostname.txt ( has 162 hostnames )
I tried :
sed -i 's/Hostname/Hostname.txt/gI' Paths.txt
But the result is :
\\Hostname.txt\example1\example1.txt
\\Hostname.txt\example2\example2.txt
It did not read the real hostname inside the file Hostname.txt
sed
. – Artur Meinild Apr 07 '22 at 09:23