Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'd like to pipe the output of an ldapsearch to sanitize the dates returned - I presume sed and/or awk can help with this but would appreciate a bit of help.

The fixed length date format in the LDIF output file is like this:

whenCreated: 20111209103130.0Z

Any pointers to get it in this format would be great:

whenCreated: DD-MM-YY hh:mm 

eg (using above example):

whenCreated: 09-12-2011 10:31
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Does this little piece of sed help you?

sed -e 's/whenCreated: \([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\).*/whenCreated: \3-\2-\1 \4:\5/g'
share|improve this answer
    
Wow - PERFECT - I think it would have taken me a while to work that out! Many thanks. –  Linker3000 Dec 14 '11 at 13:06
    
You're welcome. :) –  Janne Pikkarainen Dec 14 '11 at 13:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.