Why can't "[[:space:]]" match Line Feed(LF) on grep command?
Issue
-
Why can't "[[:space:]]" match Line Feed(LF) on grep command?
# cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 # grep "[[:space:]]localhost" /etc/hosts 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 # grep "[[:space:]]localhost[[:space:]]" /etc/hosts # -
I expect the following. Because "[[:space:]]" includes LF.
# grep "[[:space:]]localhost[[:space:]]" /etc/hosts 127.0.0.1 localhost.localdomain localhost
Environment
-
Red Hat Enterprise Linux 4
-
Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
