0

I am on ubuntu 12.04. Following expression:

echo abcd123 | sed 's/\([a-z]*\).*/\1/'

is supposed to get result as "abcd". But I am getting "abcd123". WHY??

Using following site as SED tutorial: SED tutorial by Bruce Barnett

4
  • The expression you typed above should indeed work (and does work for me on my shell). Try /bin/sed instead of just sed (in case sed is aliased to something weird on your system)?
    – dg99
    Nov 15, 2013 at 19:28
  • Yes. /bin/sed works. Thanks for the quick comment dg99. +1
    – jdek
    Nov 15, 2013 at 20:03
  • Now I'm curious what sed is pointing to on your machine! Could you run type sed and paste what it returns?
    – dg99
    Nov 15, 2013 at 20:21
  • sorry dg99. I was working on a project.I just did a type sed and shows "/bin/sed". But I shutdown my computer last time and I can't recreate the same error. It's working fine now and I have been using SED extensively now. Its a great tool. Again thanks for your help.
    – jdek
    Nov 16, 2013 at 18:54

1 Answer 1

0

Your sed command looks fine. I just checked your posted snippet on my own Ubuntu 12.04.1 LTS box and it worked perfectly. Sed is one of those tools that has been around forever, so it is unlikely (though certainly not impossible) that 12.04 has a broken sed. Very strange...

3
  • "I have no answer" is not really an answer. Perhaps use the Comment function to ask for more information from OP.
    – dg99
    Nov 15, 2013 at 19:39
  • I cannot comment yet (see rep points). I was simply pointing out that, as presented, his sed command was correct. Nov 15, 2013 at 21:12
  • Ah, my bad. I forgot about the rep limit thing. :(
    – dg99
    Nov 16, 2013 at 22:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .