在linux 编辑 sh文件
filename=`date +%Y%m%d`
目前只有日期 而没有当天的时间
请问 在后面加上时间 怎么变小呢
filename=`date +%Y%m%d%H`
在这里加上 %H
就会报错 !、
求sh文件编辑 高手 指导一下
filename=`date +%Y%m%d %H:%M:%S`
报错信息如下
date: extra operand ‘%H:%M:%S’
Try 'date --help' for more information.
You need to escape the spaces, or make a slight change, wrap the entire formatting parameters in single quotes, and add variable references on the outer layer, so it doesn’t matter how many spaces you put in the middle. The code is as follows
filename=
date +%Y%m%d%H
Will this cause an error? What system are you using? I tried it in my centos virtual machine and it worked fine. As for filename=
date +%Y%m%d %H:%M:%S
, change it to filename=date +%Y%m%d %H:%M:%S
; thenEscape spaces or pass '%H:%M:%S' as the second parameter