shell常用代码块
来源:互联网 发布:淘宝耐克正品店铺 贴吧 编辑:程序博客网 时间:2024/05/17 22:49
获取系统当前时间戳
current=`date "+%Y-%m-%d %H:%M:%S"` timeStamp=`date -d "$current" +%s` currentTimeStamp=$((timeStamp*1000+`date "+%N"`/1000000)) #将current转换为时间戳,精确到毫秒 echo $currentTimeStamp
将终端的输出重定向到文件
[Shell 输入/输出重定向](http://www.runoob.com/linux/linux-shell-io-redirections.html)
截取字符串中的数字
echo "2014年7月21日" | tr -cd "[0-9]"
shell的字符串和数字的转化(数字自动做字符串处理,变量名做字符串输出用单引号)
http://blog.csdn.net/longshenlmj/article/details/14166193
管道文件读取得坑
http://sunlujing.iteye.com/blog/1918907
Shell编程中的数组定义、遍历
http://blog.csdn.net/xujingzhong0077/article/details/53667279
expr,怎么老提示non-numeric argument错误
export 不支持浮点运算
https://zhidao.baidu.com/question/2118037328359190867.html
linux shell 实现 四则运算(整数及浮点) 简单方法
http://www.cnblogs.com/chengmo/archive/2010/09/30/1839556.html
如果文件存在 删除
if [ -e $FILE ]then rm -f $FILEfi
shell休眠sleep
- 方法1. sleep 0.01
- 方法2.usleep 10000 (usleep为十的负六次方秒,详细见man usleep)
$# -lt 4
$# 取得shell脚本参数个数,-lt 即 less than,小于$0 取得脚本名称(包含路径)
if [ -z ${BASEDIR} ];then
判断变量是否为空
使用sh -x调试shell脚本
http://blog.chinaunix.net/uid-20564848-id-73502.html
sehll 获取文件锁
http://www.jb51.net/article/58757.htm
开启http服务
python -m SimpleHTTPServer 8004
检查参数个数
if [ $# -lt 7 ];then
shell 常用判断
-d :判断制定的是否为目录-z:判断制定的变量是否存在值-f:判断制定的是否为文件-L:判断制定的是否为符号链接-r:判断制定的是否可读-s:判断存在的对象长度是否为0-w:判断制定的是否可写-x:判断存在的对象是否可以执行!:测试条件的否定符号
阅读全文
0 0
- shell常用代码块
- Shell 实用代码块
- shell 块代码注释
- Jquery常用代码块
- JS常用代码块
- Android 常用代码块
- angularjs常用代码块
- android常用代码块
- iOS常用代码块
- js常用代码块
- JS常用代码块
- Xcode 常用代码块
- angularjs 常用代码块
- JS常用代码块
- Xcode常用代码块
- Xcode 常用代码块
- ImageLoader 常用代码块
- golang常用代码块
- Ubuntu14.04上配置caffe
- nodejs浏览器跨域问题解决
- 学习SpringMVC——配置文件和第一个SpringMVC应用
- 异常
- CXF发布restful WebService的入门例子(客户端)
- shell常用代码块
- BZOJ 3036 绿豆蛙的归宿
- 不知道说点什么才好
- 在线将chm转为pdf
- 源码编译安装gcc-5.3.0
- 大字段的设置--lobHandler
- windows下使用net-snmp实现agent扩展(一)
- java基础知识(一)
- 数据库基础 (关系数据库)