Use the -P flag for Perl compatible regular expressions.
Let’s recall our test.txt file with the following content:
sad
happy
awake
coffee
work
schoolLet’s add a line with digits.
$ echo "3.14" >> test.txt
$ cat test.txt
sad
happy
awake
coffee
work
school
3.14In Perl, \d is a regular expression that matches on numerical digits.
Let’s try executing a grep command with it.
$ grep "\d" test.txt
sadAs you can see, there is a match on the literal d as oppose to matching on digits.
Running the command with the -P flag should do the trick:
$ grep -P "\d" test.txt
3.14