bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

awk info page should mention how to do case/switch in awk


From: Dan Jacobson
Subject: awk info page should mention how to do case/switch in awk
Date: 04 Jun 2001 03:43:37 +0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Somewhere in
File: gawk.info,  Node: Statements
there should be a paragraph about "looking for a switch/case statement
in awk?  Sorry, there is none.  The best way to get the same effect
however, would be ...."

In Node: Getopt Function we see sort of an example, but not a simple
one for our purposes.

By the way, there it says
"... highlights one of the greatest weaknesses in
`awk', which is that it is very poor at manipulating single
characters.
Repeated calls to `substr' are necessary for accessing individual
characters (*note Built-in Functions for String Manipulation: String
Functions.)"

OK, but maybe you don't have to be so downbeat, as we also see
in the split() item of the reference:
     Also as with input field-splitting, if FIELDSEP is the null
     string, each individual character in the string is split into its
     own array element.  (This is a `gawk'-specific extension.)

OK, anyways, regarding switch/case: make sure you put entries in the
index:
* switch statement, lack of:                     Statements.
* case statement, lack of:                     Statements.
so we can run across them.

By the way, is the actual answer just "if()else if()else if()..." or for(i in
array)something something...?

By the way, also the shell "shift" command for making $n = $n+1, also
tell us how to do that in awk in the manual.
-- 
http://www.geocities.com/jidanni Tel886-4-25854780 e-mail:restore .com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]