Give previous date as argument to shell script
7,134
With GNU date
:
previousdate=$( date -d 'yesterday' +'%F' )
sh processFile.sh "$previousdate" "$previousdate"
With macOS date
:
previousdate=$( date -j -v -1d +'%F' )
sh processFile.sh "$previousdate" "$previousdate"
Related videos on Youtube
Author by
user218332
Updated on September 18, 2022Comments
-
user218332 over 1 year
I need to execute the script by passing previous date as command line argument. It must be automated. So, how can i pass the previous date to the script?
For example:
sh processFile.sh previousdate previousdate
-
Kusalananda over 5 yearsThe correct answer may depend quite heavily on what type of Unix system this is for.
-