📄 printf3.sub
字号:
LC_ALL=CLANG=CSHELLSTART=$(date +%s)SECS=1275250155export TZ=EST5EDTprintf "%()T\n" $SECSprintf "%(abde)Z\n" -1printf "%(%e-%b-%Y %T)T\n" $SECSprintf -v v1 "%(%e-%b-%Y %T)T\n" $(date +%s)printf -v v2 "%(%e-%b-%Y %T)T\n" -1case $v1 in$v2) ;;*) echo "current time and -1 possible mismatch|$v1|$v2|" >&2 ;;esacunset v1 v2v1=$(date +%s)printf -v v2 "%(%s)T" -1case $v1 in$v2) ;;*) echo "current time mismatch:$v1|$v2|" >&2 ;;esacunset v1 v2printf "%(%x %X)T\n" $(( $SECS - 3600 ))printf -v v1 "%(%F %r)T\n" $SHELLSTARTprintf -v v2 "%(%F %r)T\n" -2case $v1 in$v2) ;;*) echo "shell start time and -2 possible mismatch|$v1|$v2|" >&2 ;;esacunset v1 v2printf "current time: %(%F %r)T\n" $SECSprintf "epoch time: %(%F %r %z)T\n" 0printf "random time: %(%F %r %z)T\n" $SECSprintf "local time: %(%a %b %e %H:%M:%S %Z %Y)T\n" $SECS# test fieldwidth, justification, precisionprintf "%-40.50(%a %b %e %H:%M:%S %Z %Y)T date-style time\n" $SECS# test fieldwidth, justification, precision, embedded parensprintf "%-40.50(%x (foo) %X)T date-style time\n" $SECS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -