Having trouble understanding usage of \d to find even and odd number.
by was123 from LinuxQuestions.org on (#5F5H0)
Hi Friends,
I have a file wherein i have strings as well as integer and a i am trying to find out all the even number using sed.
For example file.txt has below content
asdfasdfasdfasdf
asdf
45
46
35
24
458654
341
56545
657
79
when using sed -n '/\d*[02468]$/p' file.txt --> working fine
when using sed -n '/^\d*[02468]$/p' file.txt --> No output on terminal.
Also when using sed -n '/\d/p' file.txt --> it prints the first two line which shouldn't be the case i guess.
I am basically a bit confused with \d operation i know i can use [0-9] instead but still want to know where i am getting it wrong.


I have a file wherein i have strings as well as integer and a i am trying to find out all the even number using sed.
For example file.txt has below content
asdfasdfasdfasdf
asdf
45
46
35
24
458654
341
56545
657
79
when using sed -n '/\d*[02468]$/p' file.txt --> working fine
when using sed -n '/^\d*[02468]$/p' file.txt --> No output on terminal.
Also when using sed -n '/\d/p' file.txt --> it prints the first two line which shouldn't be the case i guess.
I am basically a bit confused with \d operation i know i can use [0-9] instead but still want to know where i am getting it wrong.