Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What does this command do?

grep "\bi\b" linux.txt

What is it searching for?

share|improve this question
It may be obvious, but just in case it is not, here is a note on the (significant) difference between \<...\> and \b...\b: `You can get unexpected results if you assume the two patterns behave the same... see this link – Peter.O Oct 16 '11 at 18:23
up vote 8 down vote accepted

\b in a regular expression means "word boundary".

With this grep command, you are searching for all words i in the file linux.txt. i can be at the beginning of a line or at the end, or between two space characters in a sentence.

share|improve this answer
can be in the begining or in the end?? isn't supposed to be only between spaces?? – amyassin Oct 16 '11 at 19:43
I don't find more details about that. But trying by hand with a file containing the lines "i foo" and "bar i", the regexp provided to the grep command above is matching both of them. – uloBasEI Oct 16 '11 at 19:53
More precisely, not only space, but any non-word character. Just like the -w --word-regexp switch does: grep -w "i" linux.txt. For example a line like "<i>italic</i>" also matches. – manatwork Oct 17 '11 at 6:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.