Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: awk tutoria...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 11 Topic 2222 of 2236
Post > Topic >>

Re: awk tutorial confusion

by Bruce Barnett <spamhater201+spamtrap@[EMAIL PROTECTED] > Apr 17, 2008 at 08:11 PM

Ed Morton <morton@[EMAIL PROTECTED]
> writes:

>> -------------
>> #!/bin/sh
>> awk '{print $c}' c=${1:-1}
>> ------------
>> 
>> (it defaults to printing column #1 if no arguments are given.)
>
> Thats fine as an example of a shell script, but it isn't a good example
of an
> awk script since it relies on the OS to do some processing. I don't know
what
> the Windows syntax is to accomplish the same thing but the general awk
script
> would be the much wordier:
>
>     awk -v c="$1" 'BEGIN{ c=(c==""?1:c) }{ print $c }'

Yes, but I didn't want to scare away beginners by suggesting this as
their very first AWK script.

As r <inpost@[EMAIL PROTECTED]
> implies, there is a fine balance between
assuming too much and going too fast when writing a tutorial. 

I'll make some more changes in the tutorial as you suggest - the best
I can. 
** Posted from http://www.teranews.com
**




 11 Posts in Topic:
awk tutorial confusion
r <inpost@[EMAIL PROTE  2008-04-14 01:53:41 
Re: awk tutorial confusion
Ed Morton <morton@[EMA  2008-04-14 06:00:16 
Re: awk tutorial confusion
Ed Morton <morton@[EMA  2008-04-14 06:21:55 
Re: awk tutorial confusion
Bruce Barnett <spamhat  2008-04-16 15:13:08 
Re: awk tutorial confusion
Ed Morton <morton@[EMA  2008-04-16 17:12:31 
Re: awk tutorial confusion
Bruce Barnett <spamhat  2008-04-17 20:11:28 
Re: awk tutorial confusion
Ed Morton <morton@[EMA  2008-04-17 23:48:23 
OT: Re: awk tutorial confusion
Ed Morton <morton@[EMA  2008-04-17 00:22:15 
Re: awk tutorial confusion
Bruce Barnett <spamhat  2008-04-16 14:28:50 
Re: awk tutorial confusion
r <inpost@[EMAIL PROTE  2008-04-16 14:42:52 
Re: awk tutorial confusion
Bruce Barnett <spamhat  2008-04-17 20:02:09 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 11:21:00 CDT 2008.