免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1642 | 回复: 5
打印 上一主题 下一主题

问个出处((result=$result|2)) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-04-27 14:59 |只看该作者 |倒序浏览
10可用积分
if [ $? != 0  ] ; then
        ((result=$result|4))
fi



if (($a&4))
then
        /usr/sbin/triggerwkb 2>/dev/null &
fi




这里的|以及&是做什么计算?以前没见过,man里怎么查?
没懂啊。

最佳答案

查看完整内容

bash:bitwise operators. The bitwise operators seldom make an appearance in shell scripts. Their chief use seems to be manipulating and testing values read from ports or sockets. "Bit flipping" is more relevant to compiled languages, such as C and C++, which run fast enough to permit its use on the fly.bitwise operators>= "right-shift-equal" (inverse of

论坛徽章:
23
15-16赛季CBA联赛之吉林
日期:2017-12-21 16:39:27白羊座
日期:2014-10-27 11:14:37申猴
日期:2014-10-23 08:36:23金牛座
日期:2014-09-30 08:26:49午马
日期:2014-09-29 09:40:16射手座
日期:2014-11-25 08:56:112015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:49:0315-16赛季CBA联赛之山东
日期:2017-12-21 16:39:1915-16赛季CBA联赛之广东
日期:2016-01-19 13:33:372015亚冠之山东鲁能
日期:2015-10-13 09:39:062015亚冠之西悉尼流浪者
日期:2015-09-21 08:27:57
2 [报告]
发表于 2009-04-27 14:59 |只看该作者

回复 #1 我是DBA 的帖子

bash:
bitwise operators. The bitwise operators seldom make an appearance in shell scripts. Their chief use seems to be manipulating and testing values read from ports or sockets. "Bit flipping" is more relevant to compiled languages, such as C and C++, which run fast enough to permit its use on the fly.

bitwise operators

<<

    bitwise left shift (multiplies by 2 for each shift position)
<<=

    "left-shift-equal"

    let "var <<= 2" results in var left-shifted 2 bits (multiplied by 4)
>>

    bitwise right shift (divides by 2 for each shift position)
>>=

    "right-shift-equal" (inverse of <<=)
&

    bitwise and
&=

    "bitwise and-equal"
|

    bitwise OR
|=

    "bitwise OR-equal"
~

    bitwise negate
!

    bitwise NOT
^

    bitwise XOR
^=

    "bitwise XOR-equal"

论坛徽章:
0
3 [报告]
发表于 2009-04-27 15:08 |只看该作者

回复 #2 ly5066113 的帖子

不是很懂,tim给讲一下吧。

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
4 [报告]
发表于 2009-04-27 15:08 |只看该作者
  1. ARITHMETIC EVALUATION
  2.        The shell allows arithmetic expressions to be evaluated, under certain
  3.        circumstances (see the let and declare builtin commands and Arithmetic
  4.        Expansion).   Evaluation is done in fixed-width integers with no check
  5.        for overflow, though division by 0 is trapped and flagged as an error.
  6.        The  operators and their precedence, associativity, and values are the
  7.        same as in the C language.  The following list of operators is grouped
  8.        into  levels  of equal-precedence operators.  The levels are listed in
  9.        order of decreasing precedence.

  10.        id++ id--
  11.               variable post-increment and post-decrement
  12.        ++id --id
  13.               variable pre-increment and pre-decrement
  14.        - +    unary minus and plus
  15.        ! ~    logical and bitwise negation
  16.        **     exponentiation
  17.        * / %  multiplication, division, remainder
  18.        + -    addition, subtraction
  19.        << >>  left and right bitwise shifts
  20.        <= >= < >
  21.               comparison
  22.        == !=  equality and inequality
  23.        &      bitwise AND
  24.        ^      bitwise exclusive OR
  25.        |      bitwise OR
  26.        &&     logical AND
  27.        ||     logical OR
  28.        expr?expr:expr
  29.               conditional operator
  30.        = *= /= %= += -= <<= >>= &= ^= |=
  31.               assignment
  32.        expr1 , expr2
  33.               comma
复制代码

论坛徽章:
23
15-16赛季CBA联赛之吉林
日期:2017-12-21 16:39:27白羊座
日期:2014-10-27 11:14:37申猴
日期:2014-10-23 08:36:23金牛座
日期:2014-09-30 08:26:49午马
日期:2014-09-29 09:40:16射手座
日期:2014-11-25 08:56:112015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:49:0315-16赛季CBA联赛之山东
日期:2017-12-21 16:39:1915-16赛季CBA联赛之广东
日期:2016-01-19 13:33:372015亚冠之山东鲁能
日期:2015-10-13 09:39:062015亚冠之西悉尼流浪者
日期:2015-09-21 08:27:57
5 [报告]
发表于 2009-04-27 15:12 |只看该作者

回复 #3 我是DBA 的帖子

位运算符。
我给的是搜索论坛的结果,waker给的是man bash的内容。

论坛徽章:
0
6 [报告]
发表于 2009-04-27 15:14 |只看该作者

回复 #5 ly5066113 的帖子

明白了。哈
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP