Hacker News .hnnew | past | comments | ask | show | jobs | submitlogin

Can't upvote this enough. Well, except that I'd replace "poorly" with "vaguely". "Implementation-defined behavior" is there for very good reasons in every single case it's there.

Sidenote: With John's name, I'd be tempted on a daily basis to change the last two letters of my name to a single 'x' ;)



You mean like this?

  $ whoami | sed 's/hr/xx/'


No, he meant:

    $ whoami | sed 's/hr$/x/'


Minor nit: She meant :)


I think you mean:

  $ echo "$PARENT" | sed 's_r/x_r$/_'
P.S. It's a bit hard to believe I misread that... thanks.


Random tip: in Bash (at least), you can execute the previous command with some changes using ^..^..^, e.g.

  $ echo john regehr | sed s/hr/xx/
  john regexx
  $ ^r/x^r$/^
  echo john regehr | sed s/hr$/x/
  john regex
(The second last line is just bash printing the new command.)


My sed knowledge isn't very advance. What is your invocation supposed to do?


You can use any separator you want in an s/../../ expression, not just /, in this case the separator is _ (this technique allows you to use / without creating a "picket fence": s/r\/x/r$\//).

So the regex just means replace "r/x" with "r$/".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: