Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

grep ips from BFD bans, invalid back reference ?

Posted on 2006-05-16
4
Medium Priority
?
804 Views
Last Modified: 2010-08-05
from shell,

bfd -a | grep '\([0-9]{1,3}(\.[0-9]{1,3}){3})\1'

Gives me the error invalid back reference,

just
bfd -a | grep -P "[0-9]{1,3}(\.[0-9]{1,3}){3}"
prints
66.232.129.62 proftpd
71.66.122.164 proftpd
89.32.206.12 proftpd
161.246.195.121 proftpd
192.16.125.78 proftpd
198.77.13.110 proftpd
203.200.74.41 proftpd
210.108.55.8 proftpd
213.195.218.239 proftpd
221.141.0.194 proftpd

How do I just capture the ip's and loose anything after it ?
0
Comment
Question by:ghboom
  • 2
4 Comments
 
LVL 15

Expert Comment

by:DonConsolio
ID: 16695784
> grep '\([0-9]{1,3}(\.[0-9]{1,3}){3})\1'

-) what are you trying to match ?
-) the number of opening and closing "(" does not match
-) the "-P" argument to grep is missing
0
 

Author Comment

by:ghboom
ID: 16695861
oops my bad,
I pasted the wrong error...
I have been trying many examples from various sources
learning about this, ultimatly I have tried

bfd -a | grep -P "\([0-9]{1,3}(\.[0-9]{1,3}){3}\)\1"

however there is no results returned...



what I am looking for is to, only have the IPs returned, not any txt.

so typing
bfd -a | grep -P "[0-9]{1,3}(\.[0-9]{1,3}){3}"
221.141.0.194 proftpd
213.195.218.239 proftpd

I would like to only have ips retrned like,

221.141.0.194
213.195.218.239

0
 
LVL 48

Accepted Solution

by:
Tintin earned 1000 total points
ID: 16696021
bfd -a | grep -P "[0-9]{1,3}(\.[0-9]{1,3}){3}" |awk '{print $1}'
0
 

Author Comment

by:ghboom
ID: 16696163
great, works like a charm !!

Thanks ;)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month10 days, 16 hours left to enroll

571 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