Программируем в ракушку SHELL
Есть файл [u]test.dat[/u]:
[code]1st_test
test-2nd
test[/code]
нужно найти в нем строку, содержащую отдельно стоящее слово [i]test[/i].
Особенность в том, что в строке [i]test-2nd[/i] после искомой [i]test[/i] стоит "минус", т.е. разделитель.
Неудачные попытки:
1. [code]:~$ grep -w test test.dat
test-2nd
test
:~$ man grep
-w, --word-regexp
Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent char acter. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore.[/code]
2.[code]:~$ grep "\<test\>" test.dat
test-2nd
test
:~$ man grep
REGULAR EXPRESSIONS
The symbols \< and \> respectively match the empty string at the beginning and end of a word.[/code]