Get the date (a day before current time) in Bash

后端 未结 17 2153
臣服心动
臣服心动 2020-11-30 17:54

How can I print the date which is a day before current time in Bash?

17条回答
  •  被撕碎了的回忆
    2020-11-30 18:16

    Use Perl instead perhaps?

    perl -e 'print scalar localtime( time - 86400 ) . "\n";'
    

    Or, use nawk and (ab)use /usr/bin/adb:

    nawk 'BEGIN{printf "0t%d=Y\n", srand()-86400}' | adb
    

    Came across this too ... insane!

    /usr/bin/truss /usr/bin/date 2>&1 | nawk -F= '/^time\(\)/ {gsub(/ /,"",$2);printf "0t%d=Y\n", $2-86400}' | adb
    

提交回复
热议问题