Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

regex pattern help - can't get a grep "regex" file to work.

Posted on 2006-11-08
2
318 Views
Last Modified: 2010-04-21
I am trying to make retrieve a regex pattern. I would like to retrieve a pattern of 1-3 digits followed by a colon followed by the same again.

For example:
$ cat test.txt
1:2:
13:26:
3:26:
333:26:
36:6:
333:263:

I would like to have all these patterns printed.
Here is what I get:
$ grep -e '\d{1,3}:d{1,3}:' test.txt
~/tmp $  

Nothing.

I will also have to be printing the same pattern with a space before and after in another file.  I have been using:
grep -e '\s\d{1,3}:d{1,3}:\s' test.txt
without success.

Any help appreciated.

Thanks,
ibanja

0
Comment
Question by:ibanja
2 Comments
 
LVL 58

Accepted Solution

by:
amit_g earned 250 total points
ID: 17899717
egrep '[0-9]{1,3}:[0-9]{1,3}' test.txt
0
 

Author Comment

by:ibanja
ID: 17901124
That certainly does it.

I noticed a typo in my question.  I had:
grep -e '\d{1,3}:d{1,3}:' test.txt
but I'd been using:
grep -e '\d{1,3}:\d{1,3}:' test.txt    

No matter.  It didn't work.

Thanks amit_g
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question