I want to write a bash script that will run on a given but process data with next days date, My current approach is to get the unix time stamp and add a days worth of seconds to it, but I cant get it working, and haven't yet found what I'm looking for online.
Here's what I've tried, I feel like the problem is that its a string an not a number, but I dont know enough about bash to be sure, is this correct? and how do I resolve this?
today="$(date +'%s')"
tomorrow="$($today + 86400)"
echo "$today"
echo "$tomorrow"
If you don't have GNU date, you can use the built-in date command with the -v option. returns tomorrow's date. returns tomorrow's date in the format YYYY-MM-DD.
Moving Date Using the Day of Week Itemsdate --date='this Fri' ## OR ## date --date='next Fri.
To get yesterday's date in bash shell you can use the Linux GNU date version with date -d yesterday or the Unix/macOS date version using date -j -v -1d .
If you have gnu-date
then to get next day you can just do:
date -d '+1 day'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With