Solved

convert all date stamps in a file using shell or perl from 02/03/2011 to 02/03/2011 format

Posted on 2011-09-02
5
275 Views
Last Modified: 2012-05-12
I want to convert all date stamps in a file using shell or perl from 02/03/2011 to 02/03/2011 format. This will modify the file not create a separate output file.
0
Comment
Question by:libertyforall2
  • 3
  • 2
5 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 36476466
You need to clarify your question as you've used the same date format.

Are you wanting to convert

DD/MM/YYYY to MM/DD/YYYY?
0
 

Author Comment

by:libertyforall2
ID: 36476483
sorry meant 02/03/2011 to 02-03-2011 mm/dd/yyyy to mm-dd-yyyy
0
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 36476490

perl -i -pe 's#(\d\d)/(\d\d)/(\d{4})#$1-$2-$3#g' file

Open in new window

0
 

Author Comment

by:libertyforall2
ID: 36476498
Is this for unix/linux? and how would I do it for all FILES in a directory ? *txt ?
0
 

Author Closing Comment

by:libertyforall2
ID: 36476502
Works great!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question