LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-13-2012, 03:51 AM   #1
anshaa
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Rep: Reputation: Disabled
replace the nth column date as MM/DD/YYYY


Hi,

I need some unix command to replace the following thing.

cat test.dat


1234|test|8/19/2009||test
1234|test|8/9/09|8/21/2009|test
1234|test||8/1/09|test

after processing


1234|test|08/19/2009||test
1234|test|08/09/2009|08/21/2009|test
1234|test||08/01/2009|test

Last edited by anshaa; 08-13-2012 at 04:26 AM.
 
Old 08-13-2012, 05:25 AM   #2
anshaa
LQ Newbie
 
Registered: Aug 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
nawk '{
for(i=3;i<=4;i++)
if((n=split($i,a,"/"))==3)
$i=sprintf("%02d/%02d/%04d",a[1],a[2],a[3])
}1' FS=\| OFS=\| infile
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to change Thunderbird's date format in Date column LXer Syndicated Linux News 0 07-18-2012 03:11 AM
[SOLVED] How do I change the System Date format to DD/MM/YYYY on RHEL Workstatio 6.1 skinutter Linux - Newbie 3 09-28-2011 09:07 AM
[SOLVED] datetime format from MM-DD-YYYY HH:MM:SS to YYYY-MM-DD HH:MM:SS hattori.hanzo Programming 4 10-13-2010 08:04 PM
[SOLVED] dd/mm/yyyy date format Ian D Linux - Newbie 4 01-11-2010 04:24 PM
Date Format dd/mm/yyyy in Suse 10.0 via Webmin collabcomp Linux - Newbie 2 09-16-2007 12:34 AM


All times are GMT -5. The time now is 12:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration