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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

switch/case in awk

Status
Not open for further replies.

superstarjpmc

Programmer
Jan 22, 2004
38
US
Hi,

I came to know that switch/case is a feature only in gawk.

What can be the equivalent of switch/case in 'awk' ?

Any efficient construct to mock switch/case in awk ?

thanks
david
 
I use do-while:
[tt]
BEGIN{
x = 3
do {
if (2==x) { print "double"; break }
if (3==x) { print "triple"; break }
if (4==x) { print "quadruple"; break }
# default
print "unknown"
} while (0)

}
[/tt]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top