📄 jshell.xml
字号:
</section>
<section>
<section_number>5</section_number>
<section_title>Wildcards</section_title>
<section_contents>
<p>
DOS has two wildcard characters, * which matches any number of
characters, and ? which matches any one character. UNIX has two
different kinds of wildcarding, "glob" patterns such as
foo*.{cc,hh}, and regular expressions.
</p>
<p>
JShell takes an intermediate position. It uses UNIX-style glob
patterns whenever a pattern is required. Regular expressions can
be more powerful, but glob patterns should be sufficient for most
purposes.
</p>
<p>
To summarize glob patterns:
</p>
<table>
<table_row>
<table_cell>*</table_cell>
<table_cell>matches zero or more characters.</table_cell>
</table_row>
<table_row>
<table_cell>?</table_cell>
<table_cell>matches exactly one character.</table_cell>
</table_row>
<table_row>
<table_cell>[abc]</table_cell>
<table_cell>matches a, b or c.</table_cell>
</table_row>
<table_row>
<table_cell>[a-zA-Z0-9]</table_cell>
<table_cell>matches any letter or digit.</table_cell>
</table_row>
<table_row>
<table_cell>{foo,bar}</table_cell>
<table_cell>matches foo or bar.</table_cell>
</table_row>
<table_row>
<table_cell>xyz</table_cell>
<table_cell>matches xyz</table_cell>
</table_row>
</table>
<p>
For example, this command lists all the .java and .class files
in the current directory:
</p>
<source>
> ls *.{java,class}
</source>
</section_contents>
</section>
<section>
<section_number>6</section_number>
<section_title>Variables</section_title>
<section_contents>
<p>
A JShell variable begins with a letter or underscore and may consist
of letters, underscores, digits and dots. Dots are permitted to
provide for namespaces. All variables set by JShell begin with
jshell. For example, jshell.prompt is the JShell prompt string.
</p>
<p>
Variables are set using the set command, e.g.
</p>
<source>
100> set FOO xyz
</source>
<p>
and examined using the env command, e.g.
</p>
<source>
101> env FOO
FOO=xyz
</source>
<p>
or the echo command:
</p>
<source>
102> echo $FOO
xyz
</source>
<p>
Note that variable names must be prefixed with $ to obtain the
variable's value.
</p>
<p>
JShell's environment variables include the JVMs System properties.
So if you type the "env" command, you'll see values for
java.class.path, os.name, and all the other System properties. You'll
also see JShell properties such as the current directory (jshell.dir),
and whether output pauses after every page of output (jshell.page).
</p>
<p>
Here is a complete list of the environment variables defined by
JShell. (Their values can be obtained by running the command
"env 'jshell*'"):
</p>
<table>
<table_row>
<table_cell>jshell.buffer</table_cell>
<table_cell>Controls whether a buffer is used in handling console output.</table_cell>
</table_row>
<table_row>
<table_cell>jshell.columns</table_cell>
<table_cell>The number of columns of the output console.</table_cell>
</table_row>
<table_row>
<table_cell>jshell.dir</table_cell>
<table_cell>The current directory. The value of this variable can be observed and modified using the commands pwd, dirs, cd, pushd, and popd.</table_cell>
</table_row>
<table_row>
<table_cell>jshell.flag</table_cell>
<table_cell>The character used to denote a flag.</table_cell>
</table_row>
<table_row>
<table_cell>jshell.history_size</table_cell>
<table_cell>The number of previous commands tracked by JShell.</table_cell>
</table_row>
<table_row>
<table_cell>jshell.lines</table_cell>
<table_cell>If JShell pauses after each page of output (see jshell.page), then jshell.lines determines how many lines of output constitute a page.</table_cell>
</table_row>
<table_row>
<table_cell>jshell.page</table_cell>
<table_cell>Indicates whether jshell pauses after each page of output.</table_cell>
</table_row>
<table_row>
<table_cell>jshell.prompt</table_cell>
<table_cell>The prompt character.</table_cell>
</table_row>
</table>
</section_contents>
</section>
<section>
<section_number>7</section_number>
<section_title>Strings</section_title>
<section_contents>
<p>
Any sequence of characters (possibly including escaped
characters) entered on the command line is a string. Strings may
be unquoted, quoted with a single-quote character (') or quoted
with a double-quote character ("). The rules for processing
strings come from UNIX's sh shell:
</p>
<table>
<table_row>
<table_cell></table_cell>
<table_cell>Unquoted string</table_cell>
<table_cell>Single-quoted string</table_cell>
<table_cell>Double-quoted string</table_cell>
</table_row>
<table_row>
<table_cell>Escapes</table_cell>
<table_cell>Processed</table_cell>
<table_cell>Ignored</table_cell>
<table_cell>Ignored</table_cell>
</table_row>
<table_row>
<table_cell>Glob Patterns</table_cell>
<table_cell>Expanded</table_cell>
<table_cell>Not expanded</table_cell>
<table_cell>Not expanded</table_cell>
</table_row>
<table_row>
<table_cell>Environment variables</table_cell>
<table_cell>Evaluated</table_cell>
<table_cell>Not evaluated</table_cell>
<table_cell>Evaluated</table_cell>
</table_row>
</table>
<p>
Examples:
</p>
<p>
1) These strings:
</p>
<source>
a\bc 'a\bc' "a\bc"
</source>
<p>
evaluate to abc, a\bc and a\bc respectively. (The last two
strings contain four characters each, and the second character is
the backslash.)
</p>
<p>
2) This command:
</p>
<source>
ls *.java
</source>
<p>
lists all the java sources in the current directory. But these
commands:
</p>
<source>
ls '*.java'
ls "*.java"
</source>
<p>
list a file named "*.java" if it exists.
</p>
</section_contents>
</section>
<section>
<section_number>8</section_number>
<section_title>Piping</section_title>
<section_contents>
<p>
UNIX-style piping can be done using the ^ character. (This
character was chosen instead of the more traditional | because |
is not on the 5mx keyboard.)
</p>
</section_contents>
</section>
<section>
<section_number>9</section_number>
<section_title>Redirection</section_title>
<section_contents>
<p>
UNIX-style redirection can be done for standard output (not error
output currently):
</p>
<table>
<table_row>
<table_cell><</table_cell>
<table_cell>redirects input.</table_cell>
</table_row>
<table_row>
<table_cell>></table_cell>
<table_cell>redirects output, overwriting the target file.</table_cell>
</table_row>
<table_row>
<table_cell>>></table_cell>
<table_cell>redirects output, appending to the target file.</table_cell>
</table_row>
</table>
</section_contents>
</section>
<section>
<section_number>10</section_number>
<section_title>Background tasks</section_title>
<section_contents>
<p>
A command can be run in the background by typing & at the end of
the command. For example, to get a recursive listing of your
entire file system in files.txt as a background job, you can do
this:
</p>
<source>
200> ls :lR > files.txt &
</source>
<p>
If you enter multiple commands on a line, the entire set of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -