Get current time in hours and minutes
问题 I'm trying to collect information from a system and I need to get the current time in hours and minutes. Currently I have: date | awk '{print $4}' which outputs something like: 16:18:54 How do I chop off the seconds? 回答1: Provide a format string: date +"%H:%M" Running man date will give all the format options %a locale's abbreviated weekday name (e.g., Sun) %A locale's full weekday name (e.g., Sunday) %b locale's abbreviated month name (e.g., Jan) %B locale's full month name (e.g., January)