1

I have a string:

09/May/2012:05:14:58 +0100

How to delete substring 58 +0100 from string ?

 sed 's/\:[0-9][0-9] \+0100//'

Not work

1
  • echo "09/May/2012:05:14:58 +0100" | sed 's/\:[0-9][0-9] \+0100//' -- works for me Commented May 9, 2012 at 7:55

2 Answers 2

3

It does work:

echo "09/May/2012:05:14:58 +0100"|sed 's/\:[0-9][0-9] \+0100//'

Output:

09/May/2012:05:14
Sign up to request clarification or add additional context in comments.

2 Comments

I tried it right away, but it does not work under linux mint 12 with bash. :(
If that precise command does not work on your Linux (either with or without a backslash before the plus, depending on the regex dialect), it has a bug.
0

If they're always in that format, you can just do:

s/:[^:]*$//

This basically gets rid of everything beyond (and including) the final : character (colon, followed by any number of characters that aren't a colon, to the end of the line).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.