Hi. I need assistance with the replacing of text into a specific file via a bash script.
My bash script, once run, currently provides a menu of computer names to choose.The script copies onto my system various files, depending what computer was selected in the menu.This is working OK.
Now, I need to update certain other files depending on what computer was selected.I have created an example scenario below.
I have a file called mainfile.txt and a lookup file called lookupfile.txt.
If I run my script and chose the option for Computer A, a variable is set in my script, e.g. $ComputerA
What I now need is for the �DomainName=� in my mainfile.txt to update with the full domain name of ComputerA that�s detailed in the lookupfile.txt
Lookupfile.txt
ComputerAcomputerA.testdomain.com192.168.1.1
ComputerBcomputerB.testdomain.com192.168.2.1
ComputerCcomputerC.testdomain.com192.168.3.1
Mainfile.txt
DomainName=
From researching the issue I believe I can use awk or sed.However, I have had difficulty finding examples like I to get it working.
Can anyone provide a solution (and possibly an explanation of the solution).I can re-format my lookup.txt file if required Many thanks.