I'm trying to use
sed to substitute all the patterns with digits followed immediately by a dot (such as
355.) by an empty string. So I try:
sed 's/\d+\.//g' file.txt
But it doesn't work. Why is that?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Because sed is not perl -- sed regexes do not have a
sed regular expression documentation here.
sed does not support
+ must be backslashed to get the special meaning:
The sed man page references the re_format man page. It makes 2 distinctions: (1) obsolete versus extended regular expressions; (2) non-enhanced versus enhanced regular expressions. All 4 combinations are possible. There is support in sed for both obsolete and extended, but in either case only for non-enhanced. The \d operator is a feature of enhanced regular expressions, therefore not supported by sed.