Kshell 总结之一

  Variables
A few important points here. First, spaces are not permitted on either
side of the equals sign.
Second, unlike most other programming languages, the shell has no
concept whatsoever of data types.
Because the shell has no concept of data types, variables are not
declared before they're used;

Displaying the Values of Variables
The $ character is a special character to the shell. If a valid variable
name follows the $,
the shell takes this as an indication that the value stored
inside that variable is to be substituted at that point.
(Remember, the shell performs variable substitution before it executes
the command )

The Null Value
A variable that contains no value is said to contain the null value.
It is the default case for variables that you never store values in.
When the shell performs its variable substitution, any values that are
null are completely removed
from the command line, without a trace:

The ${variable} Construct
The shell thinks filenameX is the full name of the variable because
it's composed entirely of valid variable name characters.
To avoid this problem, you can delimit the end of the variable name by
enclosing the entire name
(but not the leading dollar sign) in a pair of curly braces, as in
${filename}X

Built-in Integer Arithmetic
$((expression))
If the variable is not defined or contains a NULL string, its value is
assumed to be zero.

The Single Quote
As we mentioned, all special characters are ignored by the shell if they
appear inside single quotes.

The Double Quote
Double quotes work similarly to single quotes, except that they're not
as restrictive. Whereas the single quotes
tell the shell to ignore all enclosed characters,
double quotes say to ignore most. In particular, the following three
characters are not ignored inside double quotes:

The Back Quote
Its purpose is not to protect characters from the shell but to tell the
shell to execute the enclosed
command and to insert the standard output from the command at that
point on the command line.
The general format for using back quotes is
`command`
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值