Cut out a date/time stamp by using SED and scripting
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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)
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.