LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-01-2009, 03:18 AM   #1
studdard
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 0
Question Cut out a date/time stamp by using SED and scripting


Hello

I hope somebody will be able to give me a glue how to cut out a date time stamp out of a modifyed thunderbird adress file.

Background: I am using a small add-on to backup my thunderbird adress book to an external server. I want to use those files to sync my PDA with finchsynch afterwards.

At this point I believe the tool SED will do this job - just do not know how this is possible. A simple search and replace can not do this as the Date/Time stamp is changing all the the time.


(At a later stage I also want to do the opposite way and ..... but first I need this going )


**** file where the time stamp need to be cut out ****
// <!-- <mdb:mork:z v="1.4"/> --> Sun Feb 01 2009 21:14:27 GMT+0100 (CET)
< <(a=c)> // (f=iso-8859-1)



**** file how it should look like ****
// <!-- <mdb:mork:z v="1.4"/> -->
< <(a=c)> // (f=iso-8859-1)



Thanks for any help

studdard
 
Old 03-01-2009, 04:08 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Probably this will work:
Code:
sed 's|-->.*|-->|g'
 
Old 03-01-2009, 04:09 AM   #3
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
You can try the following:

Quote:
sed -e 's/-->.*/-->/' file
 
Old 03-01-2009, 04:15 AM   #4
JulianTosh
Member
 
Registered: Sep 2007
Location: Las Vegas, NV
Distribution: Fedora / CentOS
Posts: 674
Blog Entries: 3

Rep: Reputation: 90
Code:
$ echo '// <!-- <mdb:mork:z v="1.4"/> --> Sun Feb 01 2009 21:14:27 GMT+0100 (CET)' | sed 's/^\/\/.*mdb:mork.*--> \(...\) \(...\) \(..\) \(....\) \(..:..:..\).*/\4 \2 \3 \1 \5/'
2009 Feb 01 Sun 21:14:27
 
Old 03-01-2009, 11:58 AM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
To help learn how to understand the regex needed to perform this kind of operation, start by trying to express in words, the most generalized translation that will work. In your case, I would say something like "remove all characters between the string '-->' and the end of the string." Having done this much, the regular expression that performs this operation almost writes itself. This applies, of course, to the semantic aspects of the regex. The syntax, well, you just have to learn and memorize that part.
--- rod.
 
  


Reply



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
Shell scripting help, time/date manipulation enine Linux - Software 5 02-26-2009 08:04 PM
Using sed in a shell script to add date and time seefor Programming 3 02-25-2009 01:21 PM
How can I append the date/time stamp to commands in history? abefroman Linux - Security 2 05-29-2008 11:21 AM
Rename file based on its own date/time stamp airman99 Linux - General 19 09-05-2006 07:52 AM
Time stamp in Samba is 11 hours behind time stamp in Linux Linh Linux - General 3 09-04-2003 12:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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
Open Source Consulting | Domain Registration