In the file I have a line that says 1|host|google.com
I need to change the keyword after “host|”. There are different hosts in each file. I cannot just replace google.com as the keyword after “host|” is not the same in each file.
sed -i 's/^1|host|*$/1|host|"NewHostname"/' ."FileName"
That way you replace:
and directly write it into a file named
marks the beginning of a line and
the end so you apply your Pattern to the whole line.
matches everything so every hostname is replaced
here you can find some general knowledge about sed, since this was some basic stuff