we have the following /etc/hosts file
130.21.25.5 kafka01.bd-dm-kag.com
130.12.22.6 kafka02.bd-dm-kag.com
130.12.22.10 kafka03.bd-dm-kag.com
I want to use grep in order to match the kafka01 machine , as the following
machine=kafka01
grep -E '(\s$machine)[[:digit:]]+' /etc/hosts
but grep not matched the kafka01 ( no output from grep )
we try also
grep -E '\s$machine[[:digit:]]+' /etc/hosts
what is wrong with my syntax?
note - perl one linear or awk can be also considered if not solution from grep