Shell下syntax error: operand expected (error token is “-”)
在这个监控实时网口速率的脚本中,第21,22行存在错误:
#!/bin/bash
#Modified by lifei4@datangmobile.cn
echo ===DTmobile NetSpeedMonitor===
sleep 1
echo loading...
sleep 1ethn=$1while true
doRXpre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}')TXpre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}')sleep 1RXnext=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}')TXnext=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}')clearecho -e "\t\t\t RX \t\t TX \t\t\t TIME"RX=$((${RXnext}-${RXpre}))TX=$((${TXnext}-${TXpre}))if [ $RX -lt 1024 ];thenRX="${RX}B/s"elif [ $RX -gt 1048576 ];thenRX=$(echo $RX | awk '{print $1/1048576 "MB/s"}')elseRX=$(echo $RX | awk '{print $1/1024 "KB/s"}')fiif [ $TX -lt 1024 ];thenTX="${TX}B/s"elif [[ $TX -gt 1048576 ]];thenTX=$(echo $TX | awk '{print $1/1048576 "MB/s"}')elseTX=$(echo $TX | awk '{print $1/1024 "KB/s"}')fiecho -e "$ethn \t $RX $TX \t\t\t `date +%k:%M:%S` "done
修改后的文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
原因为,在$取值的时候,括号里面只需要跟变量即可(变量可自行进行计算),不需要对括号内进行运算的变量在进行取值操作。
1 2 3 4 5 6 7 |
|
然后就没有然后了~~~
Shell下syntax error: operand expected (error token is “-”)相关推荐
- 解决shell脚本“syntax error near unexpected token `fi‘”的问题。
解决shell脚本"syntax error near unexpected token `fi'"的问题. 参考文章: (1)解决shell脚本"syntax erro ...
- SHELL脚本“syntax error: unexpected end of file”解决方案[半原创]
SHELL脚本"syntax error: unexpected end of file"解决方案[半原创] 参考文章: (1)SHELL脚本"syntax error: ...
- 排错实战 —— 解决 c++ 工程编译错: error C2059 'string' illegal token on right side of xxx
原总结排错vs编译错误错误列表输出窗口 排错排到编译 缘起 最近,项目里出现了一个奇怪的编译错误.乍看错误提示,真有丈二的和尚,摸不着头脑的感觉.解决之后,又是这么的合情合理.具体是什么样的问题呢?一 ...
- Error:Expected linebreaks to be ‘LF‘ but found ‘CRLF‘ linebreak-style
Error:Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style 报错如下 解决办法 报错的原因主要是Eslint 导致的 找 ...
- ..\USER\stm32f10x.h(428): error: #67: expected a “}“ ADC1_2_IRQn = 18, /*!<
MDK软件编译,出现如下错误: ..\USER\stm32f10x.h(428): error: #67: expected a "}"ADC1_2_IRQn = 18, /*!& ...
- mysql perror_Linux运维知识之MySQL下perror工具查看System Error Code信息
本文主要向大家介绍了Linux运维知识之MySQL下perror工具查看System Error Code信息,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助. 在MySQL数据库 ...
- keil 5 出现 error: #67: expected a } 错误解决
使用KEIL 5一段时间,发现用keil 5 打开一些比较早的工程时,会出现大量 error: #67: expected a "}" 错误: ... Keil\STM32Fxx ...
- error RC2108: expected numerical dialog constant
在我们用图形控件Picture Control在对话框上添加图片是,经常会出现error RC2108: expected numerical dialog constant 解决方法: 双击erro ...
- 在hbase shell中执行list抛出异常:ERROR: No valid credentials provided
在hbase shell中执行list抛出异常:ERROR: No valid credentials provided 解决方法: 1.查看klist [hdfs@kjss1 ~]$ klist k ...
- error: #79: expected a type specifier
问题: error: #79: expected a type specifier 错误:# 79:预期的类型说明符 原因: void xms20tp(u8 xx); XX已被定义IO口.
最新文章
- cenos7 阿里云数据库扩容步骤
- docker 报错 /usr/bin/docker-current: Error response from daemon: driver failed programming external
- 剑指Offer #12 数值的整数次方(快速幂)
- 岭回归——减少过拟合问题
- 微信小程序错误监控方法谈
- 用Python去除扫描型PDF中的水印
- nodejs实践录:基于koa的简单web服务器
- [CENTOS7] [IPTABLES] 卸载Firewall Id安装 IPTABLES及防火墙设置
- asp.net 窗体关闭事件_关于滁州一地煤气爆炸事件!最新消息来了!
- PAIP.paip.手机离线ROOT过程总结
- android的歌词播放,android手机音乐播放器实现歌词同步
- Apollo学习笔记(8)车辆动力学模型
- 旅游吧!我在这里—旅游相册POI搜索:找回你的足迹
- 大厂内推的一些套路--校招、初中级社招
- 北京车管所 与 换领驾驶证过程
- 华为HCNA路由技术篇—OSPF协议细节详解
- 纯css实现的娃娃机web前端html页面源码
- 不等距双杆模型_对磁场中双杆模型问题的解析
- Speedoffice(word)如何修改行间距和段落间距
- Delphi ...开源!
热门文章
- java飞机大战游戏
- c语言入门视频(C语言入门视频教程,共20套,全部是经典(免费下载))
- 【IoT】创业:硬件创业之测试产品与产品本身一样重要
- kotlin转java_Kotlin 与 Java 代码之间的转换
- android5.0百度地图,百度地图安卓版5.0.0 官方版
- VC知识库1-54期合订本索引文件
- 【读书笔记《Android游戏编程之从零开始》】18.游戏开发基础(碰撞检测)
- iOS端Mock GPS定位 —— 测试、开发、玩游戏、发朋友圈等等,你都用得上(转)
- Python txt转换为excel
- 大学生创业计划书PPT模板在哪免费下?经典商业计划书PPT模板大全