search - Grep exact match "/etc" -


i make exact search of string /etc, in next file:

  -14: _etcrpm    /etc/rpm   -14: _nssdb_path       /etc/pki/nssdb   -14: _rpmds_ldconfig_cache      /etc/ld.so.cache   -14: _sysconfdir        /etc     -dkde_distribution_text="%(cat /etc/mandriva-release)" \   -14: distepoch  %(sed -e 's#.*release\ \(\s*\).*#\1#' /etc/release)   -14: distro_class       %(. /etc/sysconfig/system; echo $meta_class) 

i in output of grep, appears line contains only "/etc"

    -14: _sysconfdir        /etc 

can me that?

thank you

this should work:

grep -p "(?<=\s)/etc(?=\s|$)" file 

or:

grep -e "\s/etc(\s|$)" file 

or:

grep  "[[:space:]]/etc\([[:space:]]\|$\)" file 

output:

  -14: _sysconfdir        /etc 

-p perl regex.
-e extended regex.


Comments