简体   繁体   English

Bash如何格式化日期

[英]Bash How to format a date

I want to grep a file with the following date format: 我想grep具有以下日期格式的文件:

Thu Apr 24

At the moment I only have date +"%d %m %Y" and that's returning 24 04 2014. 目前,我只有date +"%d %m %Y" ,并且返回的日期是2014年4月24日。

How do I format to get "Thu Apr 24"? 如何格式化以获取“ 4月24日星期四”?

So I need the day month and date? 所以我需要日期和月份?

man date将建议date +"%a %b %d"

You can try 你可以试试

date +"%a %b %d"

where 哪里

   %a     locale's abbreviated weekday name (e.g., Sun)

   %b     locale's abbreviated month name (e.g., Jan)

   %d     day of month (e.g., 01)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM