Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 1
    How about reading the manual... You'll learn how to reference the matched portion, regardless of what's in the LHS. ;) Commented Jan 22, 2018 at 0:13
  • My bad, I meant $sed s/[0-9]/00/ as you can see, it has to be zero. I'm looking for a way for the digit to be the one found in the [0-9]. Commented Jan 22, 2018 at 0:20
  • "sed s/[0-9]/\0\0/" does the exact same as "sed s/[0-9]/00/" or am I missing something? Commented Jan 22, 2018 at 0:42
  • Yes. It becomes hew4r -> hew00r. I want hew44r. Also, why should I use that instead of "sed s/[0-9]/00/"? For this and the first example? Commented Jan 22, 2018 at 0:51
  • OK. in gnu sed using \0 refers to the previously matched regex. In bsd sed this is done using &. So in your case since \0 does not work, you can use sed 's/[0-9]/&&/'. Actuall using & will work even in gnu sed. Commented Jan 22, 2018 at 1:02