在一个非常愚蠢的shell中添加/减去变量

我正在编写一个 shell脚本,它可以在我的本地/ bin / sh上运行(在Ubuntu 13.04上使用),但是我非常需要在一个愚蠢的盒子上运行它,因为对变量的操作我得到了一个错误:
$((n2 - n1 + 1))

不起作用,我收到如下错误:

syntax error: you disabled math support for $((arith)) syntax

我不太了解那里的sh,但我认为这件事是忙碌的.我怎么能在这个哑壳上做数学?

编辑小程序列表

~ # busybox --list
[
arp
ash
cat
chgrp
chmod
chown
chroot
chvt
clear
cmp
cp
cut
date
dd
deallocvt
df
dmesg
du
echo
env
false
find
freeramdisk
ftpget
ftpput
grep
gunzip
gzip
hexdump
hwclock
ifconfig
ln
losetup
ls
md5sum
mkdir
mkfifo
mknod
mkswap
more
mount
mv
nslookup
ping
ping6
ps
pwd
renice
reset
rm
rmdir
route
seq
sh
sha1sum
sha256sum
sleep
sort
swapoff
swapon
switch_root
sync
tar
taskset
tee
telnet
test
tftp
time
top
touch
true
umount
uname
uniq
uptime
usleep
vconfig
vi
wget
whoami
yes
基于seq,sort -nr和uniq -u(POSIX兼容)的问题的另一个特定解决方案(n2 – n1 1).
foo()
{
    {
        seq 1 "$2"
        seq 0 "$1"
    } \
        | sort -n \
        | uniq -u \
        | grep -n "" \
        | sort -nr \
        | { read num; echo "${num%:*}"; }
}

$foo 100 2000
1901

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...