How to extract numbers from a string? September 28, 2023 by Tarik You can use tr to delete all of the non-digit characters, like so: echo toto.titi.12.tata.2.abc.def | tr -d -c 0-9