From 3cf8bdfe461789172a09a7bdb68a8c539e0ad76f Mon Sep 17 00:00:00 2001 From: PoplarYang Date: Mon, 16 May 2022 00:33:16 +0800 Subject: [PATCH] add 'current time point for N days ago or after' --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 9574b34..bc14aa9 100644 --- a/README.md +++ b/README.md @@ -1145,6 +1145,21 @@ date --date @1615852800 ``` +##### Print current time point for N days ago or after N days +```bash +# get this time a day ago +date -d"1 day ago" +"%F %H:%M:%S" + +# get this time tomorrow +date -d"-1 day ago" +"%F %H:%M:%S" + +# get this time 7 days ago +date -d"1 week ago" +"%F %H:%M:%S" + +# get this time a week ago +date -d"7 day ago" +"%F %H:%M:%S" +``` + ##### wait for random duration (e.g. sleep 1-5 second, like adding a jitter) ```bash sleep $[ ( $RANDOM % 5 ) + 1 ]