shell脚本截取日期处理
来源:互联网 发布:网络污词大全 编辑:程序博客网 时间:2024/05/01 15:41
[Author]: kwu
在linux中日期格式化固定为8位:2015-01-01
如实现 2015-1-1 需要进行字符串处理
#!/bin/sh# upload logs to hdfsyesterday2="2015-01-08"echo ${yesterday2}first=${yesterday2:5:1}second=${yesterday2:8:1}echo ${first}echo ${second}res=$yesterday2echo ${res} if [ $first -eq 0 ] && [ $second -eq 0 ]then res=${yesterday2:0:5}${yesterday2:6} res=${res:0:7}${res:8}elif [ $first -eq 0 ]then res=${yesterday2:0:5}${yesterday2:6}elif [ $second -eq 0 ]then res=${yesterday2:0:8}${yesterday2:9}fiecho ${res}
如上命令最终输出为
2015-1-8
1 0
- shell脚本截取日期处理
- shell脚本截取日期处理
- shell脚本中的日期处理
- Shell脚本截取字符串
- shell脚本字符串截取
- shell脚本字符串截取
- shell脚本截取字符串
- shell脚本截取字符串
- shell脚本截取字符串
- shell脚本字符截取
- shell 脚本的字符串截取
- shell脚本中截取字符串
- Shell脚本的字符串截取
- shell脚本的字符串截取
- shell脚本:字符串的截取
- Linux shell脚本字符串截取
- shell脚本之字符串截取
- shell脚本实现字符串截取
- 在eclipse里配置Hadoop开发环境
- Android网络请求开源框架Volley快速使用指南(2)——异步获取图片
- 在Eclipse中集成Genymotion模拟器插件
- sysfs接口函数的建立_DEVICE_ATTR
- C语言中的循环结构
- shell脚本截取日期处理
- 的南方就开始改口费疯狂的复古风飞
- Windows下安装Python模块的方法
- 一次非常有意思的SQL优化经历
- 高通发布两款物联网旗舰WiFi芯片
- 关于AS集成ndk的问题总结
- 第十周 字符串除了用C++扩充的string类型外,按C语言的传统,还可以用char *表示
- 黑马程序员-----IO流
- igbinary vs serialize vs json_encode