grep ips from BFD bans, invalid back reference ?

Posted on 2006-05-16
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,

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

How do I just capture the ip's and loose anything after it ?
Question by:ghboom
    LVL 14

    Expert Comment

    > 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

    Author Comment

    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}" proftpd proftpd

    I would like to only have ips retrned like,

    LVL 48

    Accepted Solution

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

    Author Comment

    great, works like a charm !!

    Thanks ;)

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
    I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
    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…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    733 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now