sed: Remove All Digits / Input From Input

www.lau‮oc.irutt‬m
sed: Remove All Digits / Input From Input

To remove all digits (numbers) from input using sed, you can use the following command:

sed 's/[0-9]//g'

This command will search the input for any digits in the range 0-9, and delete them. The g flag specifies that the substitution should be performed globally, on all occurrences of the pattern.

For example, if you have the following input:

This is a test 123456.

Running the sed command above will output:

This is a test .

You can also use the [:digit:] character class to remove all digits from the input:

sed 's/[:digit:]//g'

This will have the same effect as the first command, and remove all digits from the input.

By using the [0-9] pattern or the [:digit:] character class in a sed substitution, you can remove all digits from input. This can be useful for processing text data or for removing numbers from a script.

Created Time:2017-10-30 14:27:35  Author:lautturi