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

Are there any online grep tutorials that would feature some online tool for performing exercises? For example, having some predefined text sample and being told what patterns to find and so forth? It would be a very useful tool for practical learning of grep in a predictable environment.

share|improve this question
I found a great website, it has a good tutorial with a sandbox (for each lessons). plus, some exercises regexone.com/lesson/0 – Christian Sep 1 '14 at 12:46
up vote 12 down vote accepted

If you're looking for an online environment to practice your pattern matching using regex, there are a number of nice resources that allow you to play around with expressions for a given portion of text. Off the top of my head, there is: regex pal or rubular.

In terms of exercises, one idea is to search for questions tagged with [regex] on stack overflow. There are new regex questions of the form: "I have this text, I want to match this part of it" being posted all the time. You could just pick any one you feel comfortable with and try to work through it in your own time. There is also the benefit of being able to compare your solutions with the accepted answers.

To get you started there is the regex site which has a variety of great resources.

Note: although you asked about the grep command in particular, since it only utilises a subset of what regex has to offer in terms of pattern matching, I figured you would be better served focusing on regex in general. Also, there are varieties of grep that include a wider regex lexicon, such as egrep, which you might need to use eventually. See man grep for more details on its additional features/variations.

share|improve this answer
I agree with your second suggestion. That is the way I learnt using most of these tools. – Bernhard Sep 28 '12 at 7:27

I don't know if there's online resources, but local tests is fine, e.g with kiki

enter image description here

This will help you learn about regex.

The package is available in Ubuntu / Arch repository, to install it, do:

apt-get install -y kiki

Or pacman -S kiki-re on Arch.

share|improve this answer

Just a suggestion that satisfies the online and regex portion of your question:

http://gskinner.com/RegExr/ is a pretty friendly regex testing tool. It highlights results on the fly as you create your regex pattern. I use it regularly (there's also a desktop version using Adobe AIR)

As tojrobinson said, there's only a subset of regex implemented in grep, but this should be helpful for your learning process as it's instant feedback.

RegExr screenshot

share|improve this answer
+1 for gskinner.com – mtk Sep 28 '12 at 14:13

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.