Question: How Do You Increment a Date in Unix Shell Script?

Question: How Do You Increment a Date in Unix Shell Script?
Contents

How do I increment a date in Unix?

startdate=”$(date -d”$1″ +%s)”; What I need to do is iterate eight times, each time incrementing the epoch date by one day and then displaying it in the format mm–dd-yyyy.

How do I display the date in shell?

Sample shell script to display the current date and time

#!/bin/bash now=”$(date)” printf “Current date and time %sn” “$now” now=”$(date +’%d/%m/%Y’)” printf “Current date in dd/mm/yyyy format %sn” “$now” echo “Starting backup at $now, please wait…” # command to backup scripts goes here # …

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.