Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gsub

Status
Not open for further replies.

kwal

Technical User
Joined
Jan 20, 2002
Messages
1
Location
BE
Hello!
I need some help with gsub. I wonder why gsub doesn't need a print statement. If you place gsub between braces, you need a print statement, but without those braces, the thing you want will be printed without a specific statement.
Who can help me?
 
If you use gsub as a pattern, lines with substitution are selected? If there is no action specified, the default action is "print".

awk 'gsub(&quot;[Aa]&quot;,&quot;!&quot;)' <<EOD
First test line
Another test line
Last line
EOD


will give :
!nother test line
L!st line


If you use gsub in an action (inside braces), the substitution occurs but if you want to see the result you must use a print statement.

awk '{ gsub(&quot;[Aa]&quot;,&quot;!&quot;) ; print}' <<EOD
First test line
Another test line
Last line
EOD


will give :
First test line
!nother test line
L!st line
Jean Pierre.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top