robthomas
Computer
- Mar 9, 2003
- 1
I am trying to come up with the correct GREP syntax that gives me all the words, in the file (testgrep) below, that start with the letter 'l'. The test file I have is
long time ago
I lived free
In the Hinterland
1. If I run grep l testgrep I get............all the lines (as expected)
2. If I run grep ' l' testgrep I get............I lived free (as expected)
3. If I run grep '^l' testgrep I get............long time ago
With the grep 3. (see above) I would have expected I lived free
As lived starts with an 'l'.
I have tried running ['^l',' l'] to match on both expressions but this only gives all the lines in the file.
I suspect I am missing something cricial, can anyone help.
Thanks in advance
Rob Thomas
long time ago
I lived free
In the Hinterland
1. If I run grep l testgrep I get............all the lines (as expected)
2. If I run grep ' l' testgrep I get............I lived free (as expected)
3. If I run grep '^l' testgrep I get............long time ago
With the grep 3. (see above) I would have expected I lived free
As lived starts with an 'l'.
I have tried running ['^l',' l'] to match on both expressions but this only gives all the lines in the file.
I suspect I am missing something cricial, can anyone help.
Thanks in advance
Rob Thomas