shell问题

0809zzy 2005-12-31 05:55:32
请问shell中可不可以进行类型转换?比如一个"2"转成2
...全文
169 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
gettext 2006-01-05
  • 打赏
  • 举报
回复
let or typeset -i

let arg [arg ...]
Each arg is an arithmetic expression to be evaluated (see
ARITHMETIC EVALUATION). If the last arg evaluates to 0, let
returns 1; 0 is returned otherwise.

typeset [-afFirtx] [-p] [name[=value]]
Declare variables and/or give them attributes. If no names
are given then display the values of variables. The -p option
will display the attributes and values of each name. When -p
is used, additional options are ignored. The -F option
inhibits the display of function definitions; only the func-
tion name and attributes are printed. The -F option implies
-f. The following options can be used to restrict output to
variables with the specified attribute or to give variables
attributes:
-a Each name is an array variable (see Arrays above).
-f Use function names only.
-i The variable is treated as an integer; arithmetic eval-
uation (see ARITHMETIC EVALUATION ) is performed when
the variable is assigned a value.
-r Make names readonly. These names cannot then be
assigned values by subsequent assignment statements or
unset.
-t Give each name the trace attribute. Traced functions
inherit the DEBUG trap from the calling shell. The
trace attribute has no special meaning for variables.
-x Mark names for export to subsequent commands via the
environment.
cky41 2006-01-04
  • 打赏
  • 举报
回复
shell中的2即使字符也是数字,关键看你怎么用
alaiyeshi 2006-01-04
  • 打赏
  • 举报
回复
不知道楼主要干什么
fytzzh 2006-01-04
  • 打赏
  • 举报
回复
shell是弱类型,可以自动转换类型

bm1408 2006-01-01
  • 打赏
  • 举报
回复
什么意思?
fierygnu 2006-01-01
  • 打赏
  • 举报
回复
这两个没什么区别。

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧