linux

BASH Date Format

mysop 2022. 7. 29. 15:00
반응형

Format optionPart of DateDescriptionExample Output

date +%a Weekday Name of weekday in short (like Sun, Mon, Tue, Wed, Thu, Fri, Sat) Mon
date +%A Weekday Name of weekday in full (like Sunday, Monday, Tuesday) Monday
date +%b Month Name of Month in short (like Jan, Feb, Mar ) Jan
date +%B Month Month name in full (like January, February) January
date +%d Day Day of month (e.g., 01) 04
date +%D MM/DD/YY Current Date; shown in MM/DD/YY 02/18/18
date +%F YYYY-MM-DD Date; shown in YYYY-MM-DD 2018-01-19
date +%H Hour Hour in 24-hour clock format 18
date +%I Hour Hour in 12-hour clock format 10
date +%j Day Day of year (001..366) 152
date +%m Month Number of month (01..12) (01 is January) 05
date +%M Minutes Minutes (00..59) 52
date +%S Seconds Seconds (00..59) 18
date +%N Nanoseconds Nanoseconds (000000000..999999999) 300231695
date +%T HH:MM:SS Time as HH:MM:SS (Hours in 24 Format) 18:55:42
date +%u Day of Week Day of week (1..7); 1 is Monday 7
date +%U Week Displays week number of year, with Sunday as first day of week (00..53) 23
date +%Y Year Displays full year i.e. YYYY 2018
date +%Z  Timezone Time zone abbreviation (Ex: IST, GMT) IST
#!/bin/bash
 
d=`date +%m-%d-%Y`
echo $d    # 12-30-2017

사용방법은 위에처럼..

 

출처 : https://www.tutorialkart.com/bash-shell-scripting/bash-date-format-options-examples/

 

Bash Date Format Options - Examples

In this tutorial, we will learn the available format options for date command and how to format a date in Bash Scripting, with examples. Bash Date To format Bash Date to a required one, bash shell provides date command along with many format options. Bash

www.tutorialkart.com

 

728x90
반응형

'linux' 카테고리의 다른 글

Vim 맨위로 / 맨아래로 핫키  (0) 2022.08.24
시간 동기화 Chrony [TIME SYNC]  (0) 2022.08.19
shell.cloud.google.com 이게 머야  (0) 2022.07.28
DNS CACHING 설치 DNSMASQ  (0) 2022.07.19
firewalld 특정 아이피 차단/해제  (0) 2022.06.09