convert date format

I've been using this thread:

and

and this code:

on this format:

05/16/2008 18:30:49  Installation  48985

and I'm real close, but I got this:

2008 18:30:49  Installation  489851605

So, I'm not getting a col. setting correct, It puts $1, $2 at the end of the line and my / separator is missing.

help appreciated.

awk -F '[ /]'  '{print $1, $2, $3}' 

you need to have more than one FS value. awk accepts a character class [ ... ]
specitifcation. Solaris - use nawk.

echo '05/16/2008 18:30:49  Installation  48985' | nawk '{split($1,a,"/");$1=a[3] "/" a[2] "/" a[1]}1'
echo '05/16/2008 18:30:49  Installation  48985' | sed 's#^\(..\)/\(..\)/\(....\)#\3/\2/\1#'
1 Like

using perl

 echo '05/16/2008 18:30:49  Installation  48985' | perl -pe 's/(\d{2})\/(\d{2})\/(\d{4})(.*)/$3\/$2\/$1$4/'