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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
This article will help you understand what HashTables are and how to use them in PowerShell.
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now