@Sai, попробуйте следующее:
awk -vHOST=$(hostname -s) '/clientName =/{print $0 FS HOST;;next} /targetUri/{gsub(/contact support team/,HOST,$0);print;next} 1' Input_file > temp_file && mv temp_file Input_file
Так вот я подставляя CLIENTNAME = с его значения имени и бокса вместе с (контактная группа поддержки) струны значение с именем окна, затем я помещаю его во временный файл, а затем переименовываю этот временный файл в настоящий Input_file.
EDIT: изменение кода в соответствии с кодом OP.
awk -vHOST=$(hostname -s) '/clientName =/{$0=$0 FS HOST;print;next} /targetUri/{gsub(/contact support team/,"example.com",$0);print;next} 1' Input_file > temp_file && mv temp_file Input_file
EDIT2: @Sai, любезно пройти через следующее.
awk -vHOST=$(hostname -s) #### creating a variable named HOST whose value is command's hostname -s's value.
'/clientName =/ #### searching for string clientName = in every line and if this string found then do following.
{print $0 FS HOST #### printing the value of current line along with the FS field separator with value of HOST variable here.
;next} #### putting next here for skipping all further statements here.
/targetUri/ #### search for string targetUri for every line and if string found in any line then do following.
{gsub(/contact support team/,"example.com",$0); #### substitute the value of string (contact support team) to "example.com" in that line then.
print; #### print the newly formed line(which as example.com value in it).
next #### using next keyword I am requesting awk not to proceed with further statements now.
} 1' #### awk works on condition{action} method, so if any condition is TRUE then action following it should work
so by putting 1 I am making condition as TRUE and not mentioning any action so by default action print will happen.
Input_file > temp_file #### put all the processed output into temp_file file.
&& mv temp_file Input_file #### &&(if previous awk command ran successfully then do this command) rename temp_file to Input_file now.
Он работал только с обновлением clientName, но не заменяя «службу поддержки контактов» на example.com. – Sai
@Sai: Я изменил код сейчас, любезно посмотрите на него. – RavinderSingh13
Спасибо! Он работал теперь, как ожидалось. – Sai