let

对shell变量执行算术运算,提供常用运算符还提供了方幂**运算符。在变量的房屋计算中不需要加上$来表示变量,如果表达式的值是非0,那么返回的状态值是0;否则,返回的状态值是1

语法

  let expression [expression]

用法

 自加操作let no++
 自减操作let no--
 简写形式let no+=10,let no-=20,分别等同于let no=no+10,let no=no-20

实例



#!/bin/bash
let a=5+4 b=9-3
echo $a $b



#!/bin/bash
let "t1 = ((a = 5 + 3, b = 7 - 1, c = 15 - 4))"
echo "t1 = $t1, a = $a, b = $b"

let 命令实例:

linux命令:let utime=$offsetutc*3600+$(date --utc +%s)+3600; date --utc --date=@${utime} --date=@${utime} --utc date +%s)+3600; --utc utime=$offsetutc*3600+$(date let let utime=$offsetutc*3600+$(date --utc +%s)+3600; date --utc --date=@${utime}rootopen.com
linux命令:let utime=$offsetutc*3600+$(date --utc +%s)+3600; date --utc --date=@${utime} --date=@${utime} --utc date +%s)+3600; --utc utime=$offsetutc*3600+$(date let let utime=$offsetutc*3600+$(date --utc +%s)+3600; date --utc --date=@${utime}rootopen.com
2018-03-16 13:12:48

linux命令:let NOW=`date +%s`/86400 ; PASS_LAST_CHANGE=`grep $USER /etc/shadow | cut -d: -f3` ; PASS_LIFE=`grep $USER /etc/shadow | cut -d: -f5`; DAYS_LEFT=$(( PASS_LAST_CHANGE + PASS_LIFE - NOW)) ; echo $DAYS_LEFT $DAYS_LEFT echo ; NOW)) - PASS_LIFE + PASS_LAST_CHANGE DAYS_LEFT=$(( -f5`; -d: cut | /etc/shadow $USER PASS_LIFE=`grep ; -f3` -d: cut | /etc/shadow $USER PASS_LAST_CHANGE=`grep ; +%s`/86400 NOW=`date let let NOW=`date +%s`/86400 ; PASS_LAST_CHANGE=`grep $USER /etc/shadow | cut -d: -f3` ; PASS_LIFE=`grep $USER /etc/shadow | cut -d: -f5`; DAYS_LEFT=$(( PASS_LAST_CHANGE + PASS_LIFE - NOW)) ; echo $DAYS_LEFTrootopen.com
linux命令:let NOW=`date +%s`/86400 ; PASS_LAST_CHANGE=`grep $USER /etc/shadow | cut -d: -f3` ; PASS_LIFE=`grep $USER /etc/shadow | cut -d: -f5`; DAYS_LEFT=$(( PASS_LAST_CHANGE + PASS_LIFE - NOW)) ; echo $DAYS_LEFT $DAYS_LEFT echo ; NOW)) - PASS_LIFE + PASS_LAST_CHANGE DAYS_LEFT=$(( -f5`; -d: cut | /etc/shadow $USER PASS_LIFE=`grep ; -f3` -d: cut | /etc/shadow $USER PASS_LAST_CHANGE=`grep ; +%s`/86400 NOW=`date let let NOW=`date +%s`/86400 ; PASS_LAST_CHANGE=`grep $USER /etc/shadow | cut -d: -f3` ; PASS_LIFE=`grep $USER /etc/shadow | cut -d: -f5`; DAYS_LEFT=$(( PASS_LAST_CHANGE + PASS_LIFE - NOW)) ; echo $DAYS_LEFTrootopen.com
2018-02-07 06:05:48

Linux的Bash命令行(A-Z排序)