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
271 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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.
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

773 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