⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 482-484.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Configuration and Installation:Programming in Linux</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=1558285660//-->

<!--TITLE=Linux Configuration and Installation//-->

<!--AUTHOR=Patrick Volkerding//-->

<!--AUTHOR=Kevin Reichard//-->

<!--AUTHOR=Eric Foster//-->

<!--PUBLISHER=IDG Books Worldwide, Inc.//-->

<!--IMPRINT=M & T Books//-->

<!--CHAPTER=10//-->

<!--PAGES=482-484//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="480-482.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ewtoc.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>The preceding <B>gawk</B> program will print out the text &#147;<I>Workers for Spacely Sprockets&#148;</I> before printing each line in the <B>workers</B> file. One the command line, this will look like the following (if we stored the preceding <B>gawk</B> program in a file named <B>gawk.2</B>):</P>

<!-- CODE SNIP //-->

<PRE>

          gilbert:/$ gawk -f gawk.2 workers

          Workers for Spacely Sprockets



          Eric    286     555-6674        erc     8

          Geisha  280     555-4221        geisha  10

          Kevin   279     555-1112        kevin   2

          Tom     284     555-2121        spike   12

</PRE>

<!-- END CODE SNIP //-->

<P>The print "" prints a blank line.

</P>

<P>The <I>END</I> statement similarly lists commands to execute after all data is read. Here&#146;s where the <B>NR</B> command, number of records (or lines), comes in handy, as in the following example:</P>

<!-- CODE SNIP //-->

<PRE>

     BEGIN &#123; print "Workers for Spacely Sprockets"; print "" &#125;



     &#123; print &#125;



     END &#123; print "There are ",

                NR,

                " employees left after the latest wave of layoffs." &#125;

</PRE>

<!-- END CODE SNIP //-->

<P>This example uses cleaner formatting for the END statements. It would make no difference in the output if we had instead placed the entire <B>END</B> command on one line. We can name this file <B>gawk.3</B> and then execute the following command:</P>

<!-- CODE SNIP //-->

<PRE>

          gilbert:/$ gawk -f gawk.3 workers

          Workers for Spacely Sprockets



          Eric    286     555-6674        erc     8

          Geisha  280     555-4221        geisha  10

          Kevin   279     555-1112        kevin   2

          Tom     284     555-2121        spike   12

          There are  4  employees left after the latest wave of layoffs.

</PRE>

<!-- END CODE SNIP //-->

<P>This brief explanation covers <B>gawk</B> in the simplest terms. For example, <B>gawk</B> includes most of the trappings of a full programming language, including loops, variables, string operations, numeric operations, and the creation and manipulation of arrays. If you&#146;re interested in a useful programming language that can be mastered relatively quickly, we recommend further reading on <B>gawk</B>; our recommendations can be found in Appendix A.</P>

<H3><A NAME="Heading23"></A><FONT COLOR="#000077">Summary</FONT></H3>

<P>We realize that many of you are potential and practicing programmers, so we spent a great deal of space on the many programming tools available with Linux. Even so, we&#146;ve barely touched the surface of the Linux programming environment, for both traditional character-based programs and those running under the X Window System.

</P>

<P>The chapter began with a discussion of the GNU C compiler, <B>gcc</B>, which ships with Linux. With <B>gcc</B>, you can create and compile C, C&#43;&#43;, and Objective-C programs, as explained in this chapter.  You learned about compiling the long way and the short way, using the <B>make</B> command.</P>

<P>The chapter then discussed programming under the X Window System and the programming libraries you&#146;ll need. A freeware library called LessTif acts as a substitute for the commercial Motif programming libraries. While LessTif is clearly a work in progress, it&#146;s interesting enough for us to include on the second accompanying CD-ROM&#151;and it should be interesting enough for you to look at if you&#146;re at all interested in Motif programming.</P>

<P>In addition, you learned about the <B>imake</B> command, which is used by many X Window applications for compiling on various operating systems.</P>

<P>The Tcl/Tk combination allows you to create Motif-like interfaces through the use of a relatively easy-to-master scripting language. We provided an example script that throws a toolbar on the screen.</P>

<P>Perl is a hot scripting language, made hotter by its widespread use on the Internet. But you should be able to take advantage of its many uses, even if you never go near the Internet.</P>

<P>In what should come as a shock to no one, Linux features yet another command from the GNU Project, <B>gawk</B>, which is the functional equivalent of the <B>awk</B> programming language. <B>Gawk</B> works best on structured commands, although it does have extended programming capabilities.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="480-482.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="../ewtoc.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -