📄 2.1.htm
字号:
src="2.1.files/spacer.gif" width=1 border=0></TD></TR>
<TR>
<TD class=v1 align=middle width=188 height=1><IMG height=1
src="2.1.files/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE></DIV></FORM></TD>
<TD align=middle>
<TABLE width="95%">
<TBODY>
<TR>
<TD class=v2 align=middle>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=15> </TD></TR>
<TR>
<TD class=v2 vAlign=top><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=print&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-2-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"
target=_new><IMG height=12 src="2.1.files/img_print.gif"
width=14 align=textTop border=0></A> <A class=v2
title="Printer-friendly version of this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=print&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-2-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"
target=_new>Print</A> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=email&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-2-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"><IMG
height=9 hspace=3 src="2.1.files/img_email.gif" width=15
align=absMiddle border=0></A> <A class=v2
title="E-Mail this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=email&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-2-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1">E-Mail</A>
<A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=bookmark&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-2-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"><IMG
height=14 hspace=3 src="2.1.files/img_bookmarks.gif" width=6
align=absMiddle border=0></A> <A class=v2
title="Add a bookmark about this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=bookmark&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-2-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1">Add
Bookmark</A></TD>
<TD class=v2 vAlign=top align=right> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-2&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"><IMG
height=16 src="2.1.files/btn_prev.gif" width=56
align=absMiddle border=0></A> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-2-SECT-2&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"><IMG
height=16 src="2.1.files/btn_next.gif" width=41
align=absMiddle border=0></A></TD></TR></TBODY></TABLE>
<HR SIZE=1>
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top width=67 rowSpan=3><IMG
src="2.1.files/ruby_xs.gif" width=67 border=0></TD>
<TD class=v2 vAlign=top><A class=v1
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1&srchText=">Ruby
in a Nutshell</A><BR>By Yukihiro Matsumoto<BR></TD></TR>
<TR>
<TD class=v2> </TD></TR>
<TR>
<TD class=t1 vAlign=bottom>Chapter 2. Language
Basics</TD></TR></TBODY></TABLE>
<HR SIZE=1>
<BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top><A name=ruby-CHP-2-SECT-1></A>
<H3 class=docSection1Title>2.1 Command-Line Options</H3><A
name=ruby-IDXTERM-21></A>
<P class=docText><A name=IXT-2-126792></A>Like most scripting
language interpreters, Ruby is generally run from the command
line. The interpreter can be invoked with the following
options, which control the environment and behavior of the
interpreter itself: </P><PRE>ruby [ <TT><I>options</I></TT> ] [梋 [ <TT><I>programfile</I></TT> ] [ <TT><I>argument</I></TT>... ]</PRE><A
name=IXT-2-126793></A><A name=IXT-2-126794></A><A
name=IXT-2-126795></A><A name=IXT-2-126796></A><A
name=IXT-2-126797></A><A name=IXT-2-126798></A><A
name=IXT-2-126799></A><A name=IXT-2-126800></A><A
name=IXT-2-126801></A><A name=IXT-2-126802></A><A
name=IXT-2-126803></A><A name=IXT-2-126804></A><A
name=IXT-2-126805></A><A name=IXT-2-126806></A><A
name=IXT-2-126807></A><A name=IXT-2-126808></A><A
name=IXT-2-126809></A><A name=IXT-2-126810></A><A
name=IXT-2-126811></A><A name=IXT-2-126812></A><A
name=IXT-2-126813></A><A name=IXT-2-126814></A><A
name=IXT-2-126815></A><A name=IXT-2-126816></A><A
name=IXT-2-126817></A><A name=IXT-2-126818></A><A
name=IXT-2-126819></A><A name=IXT-2-126820></A><A
name=IXT-2-126821></A><A name=IXT-2-126822></A><A
name=IXT-2-126823></A><A name=IXT-2-126824></A><A
name=IXT-2-126825></A><A name=IXT-2-126826></A><A
name=IXT-2-126827></A><A name=IXT-2-126828></A><A
name=IXT-2-126829></A><A name=IXT-2-126830></A><A
name=IXT-2-126831></A><A name=IXT-2-126832></A><A
name=IXT-2-126833></A><A name=IXT-2-126834></A><A
name=IXT-2-126835></A><A name=IXT-2-126836></A><A
name=IXT-2-126837></A><A name=IXT-2-126838></A><A
name=IXT-2-126839></A><A name=IXT-2-126840></A><A
name=IXT-2-126841></A><A name=IXT-2-126842></A><A
name=IXT-2-126843></A><A name=IXT-2-126844></A><A
name=IXT-2-126845></A><A name=IXT-2-126846></A><A
name=IXT-2-126847></A><A name=IXT-2-126848></A><A
name=IXTR3-0></A>
<DL class=docList><A name=IXT-2-126793></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-a</SPAN></SPAN></SPAN>
<DD>
<P class=docList><A name=IXT-2-126794></A>Used with
<TT>-n</TT> or <TT>-p</TT> to split each line. Split output
is stored in <TT>$F</TT>. </P><A name=IXT-2-126795></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-c</SPAN></SPAN></SPAN>
<DD>
<P class=docList><A name=IXT-2-126796></A>Checks syntax
only, without executing program. </P><A
name=IXT-2-126797></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-C dir</SPAN></SPAN></SPAN>
<DD>
<P class=docList><A name=IXT-2-126798></A>Changes directory
before executing (equivalent to <TT>-X</TT>). </P><A
name=IXT-2-126799></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-d</SPAN></SPAN></SPAN>
<DD>
<P class=docList><A name=IXT-2-126800></A><A
name=IXT-2-126801></A>Enables debug mode (equivalent to
<TT>-debug</TT>). Sets <TT>$DEBUG</TT> to <TT>true</TT>.
</P><A name=IXT-2-126802></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-e</SPAN></SPAN>
<TT><I>prog</I></TT></SPAN>
<DD>
<P class=docList>Specifies <TT><I>prog</I></TT> as the
program from the command line. Specify multiple <TT>-e</TT>
options for multiline programs. </P><A
name=IXT-2-126803></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-F</SPAN></SPAN>
<TT><I>pat</I></TT></SPAN>
<DD>
<P class=docList><A name=IXT-2-126804></A><A
name=IXT-2-126805></A>Specifies <TT><I>pat</I></TT> as the
default separator pattern (<TT>$;</TT>) used by
<TT>split</TT>. </P><A name=IXT-2-126806></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-h</SPAN></SPAN></SPAN>
<DD>
<P class=docList><A name=IXT-2-126807></A>Displays an
overview of command-line options (equivalent to
<TT>-help</TT>). </P><A name=IXT-2-126808></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-i [</SPAN></SPAN>
<TT><I>ext</I></TT><SPAN class=docPubcolor><SPAN
class=docMonofont>]</SPAN></SPAN> </SPAN>
<DD>
<P class=docList><A name=IXT-2-126809></A><A
name=IXT-2-126810></A><A name=IXT-2-126811></A>Overwrites
the file contents with program output. The original file is
saved with the extension <TT><I>ext</I></TT>. If
<TT><I>ext</I></TT> isn't specified, the original file is
deleted. </P><A name=IXT-2-126812></A>
<DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN
class=docMonofont>-I</SPAN></SPAN>
<TT><I>dir</I></TT></SPAN>
<DD>
<P class=docList><A name=IXT-2-126813></A>Adds
<TT><I>dir</I></TT> as the directory for loading libraries.
</P><A name=IXT-2-126814></A>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -