Delimiters (< and >)

Are delimiters are used to identify a word in a regular expression. Let's create a file:

zarrelli:~$ echo "barnaby went to the bar to see the barnum musical" > text.file 

Now, we will grep with the word delimiter set to bar with the -o option, which will output only the fragment that matched and not all the lines containing it:

grep -o '<bar>' text.file 
bar

This is correct. There is only one single word called bar; the others are composite words, and we can double check this:

zarrelli:~$ grep -o bar text.file 
bar
bar
bar

If we do not look for the word named bar, but only for the matches of a three character string bar, we see that we can match it three times in the file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.174.239