Using the command:
CURRTIME=`date "+%Y%m%d%k%M%S"`
I can get the current time string such as "20120827141534". I want to use this string to make a file . But when it is before 10 a clock, it can't runs well. The string will be spearate Because the the hour string has only one digit with space before it. CURRTIME will be like this:20120827 41534. How can I deal with it?
Use %H
instead of %k
:
CURRTIME=`date "+%Y%m%d%H%M%S"`
%k
is space padded (obviously). but %H
adds a padded 0.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.