2

I'm looking to replace the exiting date format (CCYY-MM-DD) with MM-DD-CCYY date format in a large file using shell script. Before changing the date format, it should look like:

2014-01-31|2014-01-31|

And after change the date format should it look like:

01-31-2014|01-31-2014|

1 Answer 1

5

Using sed you can do it:

sed -i.bak -r 's/([0-9]{4})-([0-9]{2})-([0-9]{2})/\2-\3-\1/g' file
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.