1。获取今天日期的各种用法:
[[email protected] ~]# date +%Y_%m_%d
2016_05_22
[[email protected] ~]# date ‘+%Y_%m_%d‘
2016_05_22
[[email protected] ~]# date "+%Y_%m_%d"
2016_05_22
[[email protected] ~]# date +‘%Y_%m_%d‘
2016_05_22
[[email protected] ~]# date +"%Y_%m_%d"
2016_05_22
[[email protected] ~]# date -d today +%Y_%m_%d
2016_05_22
[[email protected] ~]# date -d today ‘+%Y_%m_%d‘
2016_05_22
[[email protected] ~]# date -d today "+%Y_%m_%d"
2016_05_22
[[email protected] ~]# date -d today +‘%Y_%m_%d‘
2016_05_22
[[email protected] ~]# date -d today +"%Y_%m_%d"
2016_05_22
2.注意事项:date后面必须有一个空格;+后面不能有空格;以上所用是单引号和双引号。
3.如果与其他命令使用,需要用到反引号``,键盘上位于感叹号!左边的~键上。例如:
[[email protected] ~]# echo `date -d today +%Y_%m_%d`
2016_05_22
[[email protected] ~]# echo `date -d today +‘%Y_%m_%d‘`
2016_05_22
[[email protected] ~]# echo `date -d today +"%Y_%m_%d"`
2016_05_22
4.oracle中获取当天时间的办法:
SQL> select to_char(sysdate,‘yyyy_mm_dd‘) from dual;
2016_05_22