Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using sed, how would I change Popeye’s birthday to 11/14/46? Assume you don’t know Popeye’s original birthday.

The input filename is datebook, as follows:

Arthur Putie:923-835-8745:23 Wimp Lane, Kensington, DL 38758:8/31/69:126000
Popeye Sailor:156-454-3322:945 Bluto Street, Anywhere, USA 29358:3/19/35:22350
Jose Santiago:385-898-8357:38 Fife Way, Abilene, TX 39673:1/5/58:95600

I tried

sed ‘^\(/Popeye/s/[0-9]{5}\):/\1:11/14/46’ datebook 

but it did not work.

share|improve this question
What is your question? You want to write a parser to pick out the relevant data and replace it for you? That might be better on Stack Overflow, but as it is I'm not even sure this is a real question. – Shinrai Oct 4 '12 at 19:58
Reopened since after the OP's clarification, this question became answerable. – slhck Oct 4 '12 at 20:53
up vote 2 down vote accepted

There are numbers, slash, numbers, slash, numbers. Use an alternate separator to avoid backslashed slashes:

sed '/Popeye/s,[0-9]\+/[0-9]\+/[0-9]\+,11/14/46,'
share|improve this answer
Thank you Choroba. Appreciate your help. – Steve Oct 4 '12 at 20:42
sed '/Popeye/s,[0-9]\+/[0-9]\+/[0-9]\+,11/14/46,' => This works great. Thank you Choroba – Steve Oct 5 '12 at 7:36

Your Answer


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.