#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    232
    Rep Power
    17

    Grepping hostnames


    Hey guys,

    Trying to grep hostnames out of a file as part of a shell script:

    So anything between (space character) or ' and .domain.com.

    Code:
    grep -E "\([:space:]|\'\)(.*?).domain.com" index.html
    What am I doing wrong?

    Cheers,

    Dreza
    PHP and C++ Programmer.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    153
    Rep Power
    2
    Not good with grep but, first thing, are you using the correct switch for the job, and have you tested something really simple to see if that works? - I know from experience that these things can use some very peculiar variations of POSIX that don't follow conventional syntax.

    Also, I think that the expression needs to be something more along the lines of:

    Code:
    grep -E "\([:space:]|\'\)(.*)?\.domain\.com" index.html
    ...and I am not certain whether the escaped items in your code actually need to be escaped or not.

IMN logo majestic logo threadwatch logo seochat tools logo