Changing all date fields from mm/dd/yy to dd/mm/yy

Changing all date fields from mm/dd/yy to dd/mm/yy

Post by contrace.. » Fri, 03 Feb 2006 23:10:07



Please, I'm looking for a way to change all date fields in a specified
file, like this:

solaris> cat file

05/23/06      03/12/06

07/10/06                   11/12/06           09/20/06

      03/11/06

I need change all date field from mm/dd/yy to dd/mm/yy, like this:

solaris> ./script < cat file

23/05/06        12/03/06

10/07/06                 12/11/06             20/09/06

       11/03/06

Thanks !

 
 
 

Changing all date fields from mm/dd/yy to dd/mm/yy

Post by Xichen » Fri, 03 Feb 2006 23:40:32



> Please, I'm looking for a way to change all date fields in a specified
> file, like this:

> solaris> cat file

> 05/23/06      03/12/06

> 07/10/06                   11/12/06           09/20/06

>       03/11/06

> I need change all date field from mm/dd/yy to dd/mm/yy, like this:

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

Xicheng

Quote:> solaris> ./script < cat file

> 23/05/06        12/03/06

> 10/07/06                 12/11/06             20/09/06

>        11/03/06

> Thanks !


 
 
 

Changing all date fields from mm/dd/yy to dd/mm/yy

Post by William Jame » Sat, 04 Feb 2006 01:38:05



> Please, I'm looking for a way to change all date fields in a specified
> file, like this:

> solaris> cat file

> 05/23/06      03/12/06

> 07/10/06                   11/12/06           09/20/06

>       03/11/06

> I need change all date field from mm/dd/yy to dd/mm/yy, like this:

> solaris> ./script < cat file

> 23/05/06        12/03/06

> 10/07/06                 12/11/06             20/09/06

>        11/03/06

> Thanks !

ruby -i -pe'gsub( %r!(\d\d)/(\d\d)/(\d\d)! )
  { $~.captures.values_at(1,0,2).join "/" }' myfile
 
 
 

Changing all date fields from mm/dd/yy to dd/mm/yy

Post by Ed Morto » Sat, 04 Feb 2006 01:51:09



> Please, I'm looking for a way to change all date fields in a specified
> file, like this:

> solaris> cat file

> 05/23/06      03/12/06

> 07/10/06                   11/12/06           09/20/06

>       03/11/06

> I need change all date field from mm/dd/yy to dd/mm/yy, like this:

> solaris> ./script < cat file

> 23/05/06        12/03/06

> 10/07/06                 12/11/06             20/09/06

>        11/03/06

> Thanks !

sed 's:\(../\)\(../\)\(..\):\2\1\3:' file

Regards,

        Ed.

 
 
 

Changing all date fields from mm/dd/yy to dd/mm/yy

Post by Dan Merce » Mon, 06 Feb 2006 01:12:42


: Please, I'm looking for a way to change all date fields in a specified
: file, like this:
:
: solaris> cat file
:
: 05/23/06      03/12/06
:
: 07/10/06                   11/12/06           09/20/06
:
:       03/11/06
:
: I need change all date field from mm/dd/yy to dd/mm/yy, like this:
:
: solaris> ./script < cat file

perl -pe 's:(\d{2})/(\d{2})/(\d{2}):$2/$1/$3:g' infile >outfile

Dan Mercer

:
:
: 23/05/06        12/03/06
:
: 10/07/06                 12/11/06             20/09/06
:
:        11/03/06
:
:
: Thanks !
:

 
 
 

Changing all date fields from mm/dd/yy to dd/mm/yy

Post by C. Cook » Mon, 06 Feb 2006 02:59:23



Quote:> Please, I'm looking for a way to change all date fields in a specified
> file, like this:

<snip>

Quote:> I need change all date field from mm/dd/yy to dd/mm/yy, like this:

<snip>

Sed will do that easily:

sed 's/\([0-9][0-9]\)\/\([0-9][0-9]\)\/\([0-9][0-9]\)/\2\/\1\/\3/g'

--
for((P=10**8,Q=P/100,X=320*Q/(`tput cols`-1),Y=210*Q/`tput lines`,y=-105*Q,v=-2\
20*Q,x=v;y<105*Q;x=v,y+=Y));do for((;x<P;a=b=i=k=c=0,x+=X));do for((;a*a+b*b<2*\
P*P&&i++<99;a=((c=a)*a-b*b)/P+x,b=2*c*b/P+y));do :;done;(((j=(i<99?i%16:0)+30)>\
37?k=1,j-=8:0));echo -ne "\E[$k;$j"mE;done;echo -e \\E[0m;done # Charles Cooke

 
 
 

1. Sort by First Date Field (MM/DD/YY)

How do i sort the flat file given below. I want the file to be sorted
by the date. Any help, Please post the solution.  -TIA

11/13/02   8564528  A1 920316
09/13/02   95761826 A2 920316
12/10/02   9488073  A2 920316
08/11/02   102723151A2 920316
07/03/02   9659327  A1 920316
05/04/02   1120732  A2 920316
01/06/03   1165141  A1 920316
01/08/03   1167543  A1 920316
01/05/03   1165141  A1 920316
02/14/03   1167543  A1 920316
03/15/03   1165141  A1 920316
04/22/03   1167543  A1 920316

2. NFS questions

3. Files modified since yy/mm/dd hh:mm

4. Linux reboots after touching the mouse with shared AGP video on Motherboard

5. How to translate date in dd/mm/yy format

6. PPPlink up/not getting web pages

7. How to convert Posix date to YY/MM/DD ?

8. Kenel panics using NFS

9. How to read file modification date (mm-dd-yy) in Korn

10. sort MM/DD/YY in reverse chron order with -k...

11. HELP: C prog to get mm/dd/yy format

12. How to convert dd/mm/yy to unix epoch time?

13. Need f77 idate(mm,dd,yy) function