Hey so I want to replace a regex pattern with nothing, I've tried multiple sed routes but none seem to be working, i.e

sed -i 's/\.\d{1,3}\b$//'

Example of input,


expected output would be,

  • So what are you trying to match? You've shown us a regex that does not do what you want, but you haven't explained what you need. Are you trying to remove the last . followed by 1 to 3 numbers from each line? What if a line is foo.1234? Should we leave that unchanged?
    – terdon
    Dec 5, 2019 at 0:49
  • Yes I want to remove the last dot followed by 1 to 3 numbers from each line.
    – Valkyrie
    Dec 5, 2019 at 0:52
  • OK, so what happens with foo.1234? Nothing? Do we just print the line?
    – terdon
    Dec 5, 2019 at 0:53

1 Answer 1


Maybe yo can try something like this:

sed -i -E 's/\.[0-9]{1,3}$//' file
  • thank you for your help
    – Valkyrie
    Dec 5, 2019 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.