Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 204946 - Awk by example, Part 1 - missing command
Summary: Awk by example, Part 1 - missing command
Status: RESOLVED FIXED
Alias: None
Product: [OLD] Docs on www.gentoo.org
Classification: Unclassified
Component: Other documents (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: nm (RETIRED)
URL: http://www.gentoo.org/doc/en/articles...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-08 20:08 UTC by Jesús Guerrero Botella (RETIRED)
Modified: 2008-01-09 01:52 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
l-awk1.diff (l-awk1.diff,900 bytes, text/plain)
2008-01-08 22:44 UTC, Jesús Guerrero Botella (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesús Guerrero Botella (RETIRED) gentoo-dev 2008-01-08 20:08:59 UTC
Section 1 of that page starts like this:

============================BEGIN
The first awk

You should see the contents of your /etc/passwd file appear before your eyes. Now, for an explanation of what awk did. When we called awk, we specified /etc/passwd as our input file. When we executed awk, it evaluated the print command for each line in /etc/passwd, in order. All output is sent to stdout, and we get a result identical to catting /etc/pass.

Now, for an explanation of the { print } code block. In awk, curly braces are used to group blocks of code together, similar to C. Inside our block of code, we have a single print command. In awk, when a print command appears by itself, the full contents of the current line are printed. 
============================END

It starts speaking about something that you *should* see, but to see that, you actually would need to type a command, which is not specified.

And yes, I know this is a literal transcription of this:
http://www.ibm.com/developerworks/linux/library/l-awk1.html

But that doesn't mean tha the article is correct. Since it is aimed to inform and serve the community, I think it should be corrected. These are the kind of things that misslead newcomers.

The xml for that portion is this

============================BEGIN
<title>The first awk</title>
<body>

<p>
You should see the contents of your <path>/etc/passwd</path> file appear before
your eyes.  Now, for an explanation of what awk did. When we called awk, we
specified <path>/etc/passwd</path> as our input file. When we executed awk, it
evaluated the print command for each line in <path>/etc/passwd</path>, in
order. All output is sent to stdout, and we get a result identical to catting
<path>/etc/pass</path>.
</p>

<p>
Now, for an explanation of the { print } code block. In awk, curly braces are
used to group blocks of code together, similar to C. Inside our block of code,
we have a single print command. In awk, when a print command appears by itself,
the full contents of the current line are printed.
</p>
============================END

And I think it should be:

============================BEGIN
<title>The first awk</title>
<body>

<pre caption="The first awk">
$ <i>awk '{ print }' /etc/passwd</i>
</pre>

<p>
You should see the contents of your <path>/etc/passwd</path> file appear before
your eyes.  Now, for an explanation of what awk did. When we called awk, we
specified <path>/etc/passwd</path> as our input file. When we executed awk, it
evaluated the print command for each line in <path>/etc/passwd</path>, in
order. All output is sent to stdout, and we get a result identical to catting
<path>/etc/pass</path>.
</p>

<p>
Now, for an explanation of the { print } code block. In awk, curly braces are
used to group blocks of code together, similar to C. Inside our block of code,
we have a single print command. In awk, when a print command appears by itself,
the full contents of the current line are printed.
</p>
============================END

Note that print has no arguments, which makes concordance with the following paragraph, that explains that using $0 is the same than using nothing at all.

============================BEGIN
<pre caption="Printing the current line">
$ <i>awk '{ print $0 }' /etc/passwd</i>
$ <i>awk '{ print "" }' /etc/passwd</i>
</pre>

<p>
In awk, the $0 variable represents the entire current line, so print and print
$0 do exactly the same thing.
</p>
============================BEGIN

I hope that makes sense. English is not my native language, but I think I am right, and this should be corrected because it confuses people, harming the whole purpose that the article was written for, which is to tearch people.



Reproducible: Always

Steps to Reproduce:
1. Just open the url and read.
2.
3.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2008-01-08 22:13:04 UTC
(In reply to comment #0)
> I hope that makes sense.

It would make a whole *lot* more sense if you attached a unified diff... 
Comment 2 Jesús Guerrero Botella (RETIRED) gentoo-dev 2008-01-08 22:37:23 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > I hope that makes sense.
> 
> It would make a whole *lot* more sense if you attached a unified diff... 
> 

Of course, I know. I just wanted to make sure that the document was changeable before submiting anything. I will submit it briefly.
Comment 3 Jesús Guerrero Botella (RETIRED) gentoo-dev 2008-01-08 22:44:07 UTC
Created attachment 140502 [details]
l-awk1.diff

Patch to gentoo/xml/htdocs/doc/en/articles/l-awk1.xml, added one example that was missing.
Comment 4 nm (RETIRED) gentoo-dev 2008-01-09 01:34:02 UTC
Normally, I would point you to the line of the disclaimer that reads "This document is not actively maintained.", but in this case, yeah . . . dunno where the heck that first example went! Thanks for providing one. I also made a couple of other small changes to the paragraph below it.

Thanks for reporting, fixed in CVS.
Comment 5 Jesús Guerrero Botella (RETIRED) gentoo-dev 2008-01-09 01:47:27 UTC
(In reply to comment #4)
> Normally, I would point you to the line of the disclaimer that reads "This
> document is not actively maintained.", but in this case, yeah . . . dunno where
> the heck that first example went! Thanks for providing one. I also made a
> couple of other small changes to the paragraph below it.
> 
> Thanks for reporting, fixed in CVS.
> 
Yes, that was why, in first place, I was not sure about the bug report.

I know it is not maintained, but I felt this is something critical, and with an easy solution. I stumpped with this because I am translating the Awk by example series to spanish.

I don't know where it went either, but it is not either in the original link form the ibm site I posted above. So, I don't think that the error was made on the Gentoo side, but rather on the drobbins side or the ibm site.

Thanks to you for attending my petition, and thanks for applying the fix.

I will checkout and make sure that the spanish translation includes the correct version numbers and all the fixes. Thanks again.
Comment 6 nm (RETIRED) gentoo-dev 2008-01-09 01:52:35 UTC
(In reply to comment #5)
> I don't know where it went either, but it is not either in the original link
> form the ibm site I posted above. So, I don't think that the error was made on
> the Gentoo side, but rather on the drobbins side or the ibm site.

Yeah, it's either IBM's fault, or Daniel didn't include it in the draft he sent them. I checked our CVS history, and that example's never been in the Gentoo versions.