Substitution in AWK

I am trying to use AWK to replace dallinux02 to dallinux03 everywhere in the servers.txt file and move it over to "awk2".

Here is my script "awk2.awk":

           gsub(/dallinux02/, "dallinux03"); print > "awk2"

I am trying to run this using the following:

$ awk -f awk2.awk servers.txt

But, I am getting a syntax error. Please assist!

See if this helps.

 
 
File "awk2.awk":

{gsub(/dallinux02/,"dallinux03")}; 1

Command:
 
awk -f awk2.awk servers.txt >awk2

@ora_umair: I think the {} is missing, try the following:

awk '{gsub(/dallinux02/, "dallinux03"); print }' servers.txt > awk2

Thanks everyone for your help.

thanhdat, you are right. The problem was the missing curly braces.

In AWK, an action is defined as one or more awk commands enclosed in a pair of curly braces {}.