Monday, May 9, 2022

[SOLVED] How to replace dashes with forward slash using sed?

Issue

I am using the date function to get the date in this format

date +"%m-%d-%Y" which returns 04-25-2022. How can i replace the dashes so date is returned as 04/25/2022?


Solution

Don't use sed. Just change the format that gets passed to date.

date +"%m/%d/%Y"


Answered By - Andy Lester
Answer Checked By - Pedro (WPSolving Volunteer)