I’m fairly new to Linux and shell scripting so I hope that you will forgive a nooby question.
I want to get the current date but with a fixed time into a variable with the value in epoch seconds.
I have done this so far, but I’m really not happy with it:
startTime=$(date -d $(date +"%FT03:15:00") +%s)
It works ok but just seems a bit clunky (mainly because of the two calls to date) so was wondering if there is a better/cleaner way to achieve what I’m after?
I tried a printf alternative which cut down on one date call but...
The jobs that’s running this isn’t performance critical but I like to code for efficiency out of habit.
dateis smart enough to understand that if you say 03:15:00 without specifying the full date, that means today. Sodate -d 03:15:00 +%smight be what you want"newbie"(or justNB), not"nooby". Welcome to StackOverflow.