I tried using $(date)
in my bash shell script, however I want the date in YYYY-MM-DD format. How do I get this?
相关问题
- How to get the return code of a shell script in lu
- JQ: Select when attribute value exists in a bash a
- Date with SimpleDateFormat in Java
- Invoking Mirth Connect CLI with Powershell script
- Emacs shell: save commit message
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- In IntelliJ IDEA, how can I create a key binding t
- Check if directory exists on remote machine with s
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Reverse four length of letters with sed in unix
- MYSQL: How can I find 'last monday's date&
- Calculate number of working days in a month [dupli
With recent Bash (version ≥ 4.2), you can use the builtin
printf
with the format modifier%(strftime_format)T
:In Bash:
get year-month-day from
date
get year-month-day hour:minute:second from
date
Other available date formats can be viewed from the date man pages:
The output would be
2015-06-14
.if you want the year in a two number format such as 17 rather than 2017, do the following:
Whenever I have a task like this I end up falling back to
to remind myself of all the possibilities.
Try:
$(date +%F)