The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Change of date format svenkatareddy Shell Programming and Scripting 2 05-23-2008 03:58 AM
How Can we change the Date format from Variable laknar Shell Programming and Scripting 1 05-02-2008 03:47 AM
Change date format ust UNIX for Advanced & Expert Users 4 12-19-2007 05:17 PM
convert mmddyy date format to ccyyddd format?? Bhups Shell Programming and Scripting 2 09-28-2006 12:30 AM
change the empty function from the old format to the new format powah Shell Programming and Scripting 0 06-23-2005 01:17 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-01-2006
preethgideon preethgideon is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 71
How to change it to the date format

Hi,
I want to know how to change this string to date format

20061102122042 to 02-11-2006 12:20:42
or 02-Nov-2006 12:20:42

Please let me know at the earliest.Thanks in advance.

Regards,
Preetham R.
  #2 (permalink)  
Old 11-01-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
echo 20061102122042 | sed "s/\(.\{4\}\)\(..\)\(..\)\(..\)\(..\)\(..\)/\3-\2-\1 \4:\5:\6/"
  #3 (permalink)  
Old 11-02-2006
preethgideon preethgideon is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 71
Hey thanks for the command but the string would be in the file say as the seventh field.
  #4 (permalink)  
Old 11-02-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
Quote:
Originally Posted by preethgideon
Hey thanks for the command but the string would be in the file say as the seventh field.
then simply add this to anbu's code
cat filename|while read line
do
echo $line|awk '{print $7}'|sed "s/\(.\{4\}\)\(..\)\(..\)\(..\)\(..\)\(..\)/\3-\2-\1 \4:\5:\6/">>filename2
done

Last edited by napolayan; 11-02-2006 at 08:21 AM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0