Символ \
10.8.5 Символ обратной косой черты \
В некоторых случаях вам может понадобиться сопоставить символ, который является специальным символом регулярного выражения. Например, рассмотрим следующее:
sysadmin@localhost:~/Documents$ cat newhome.txt
Thanks for purchasing your new home!!
**Warning** it may be haunted.
There are three bathrooms.
**Beware** of the ghost in the bedroom.
The kitchen is open for entertaining.
**Caution** the spirits don't like guests.
Good luck!!!
sysadmin@localhost:~/Documents$ grep 're*' newhome.txt
Thanks for purchasing your new home!!
**Warning** it may be haunted.
There are three bathrooms.
**Beware** of the ghost in the bedroom.
The kitchen is open for entertaining.
**Caution** the spirits don't like guests.В выводе grepприведенной выше команды поиск re*соответствует каждой строке, содержащей rноль или более букв, за которыми следует e.
Чтобы найти фактический *символ звездочки, поместите \символ обратной косой черты перед символом звездочки *:
Last updated