Results 1 to 6 of 6

Thread: how to make grep ignore special characters

  1. #1
    Join Date
    Apr 2008
    Location
    /jordan.d
    Beans
    137

    how to make grep ignore special characters

    usually i use grep to search long man pages for certain options rather than going through the whole manual..however when i need to view the part related to certain option, grep interprets that option as its own which causes unexpected behaviour or displaying available options for grep..for instance i need to check what -r exactly does in userdel as in
    Code:
    man userdel | grep -r
    now grep modifies its behaviour accordingly, but i need it to search for -r in the man page instead..

    Code:
    man grep | grep exact
    ddnt really help
    any suggestions ??
    M Abu Rahmeh
    ‘—so long as I get somewhere,’ Alice added as an explanation.
    ‘Oh, you’re sure to do that,’ said the Cat, ‘if you only walk long enough.’

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: how to make grep ignore special characters

    Code:
    man userdel | grep -- -r
    -- = end options
    or
    Code:
    man userdel | grep -A 10 -- -r
    -A NUM, --after-context=NUM
    Print NUM lines of trailing context after matching lines.
    Places a line containing a group separator (--) between
    contiguous groups of matches. With the -o or --only-matching
    option, this has no effect and a warning is given.
    Last edited by sisco311; July 8th, 2008 at 12:02 AM.

  3. #3
    Join Date
    Apr 2008
    Location
    /jordan.d
    Beans
    137

    Re: how to make grep ignore special characters

    thx, this solves the problem.
    now how can i search for a sequence of words, like
    Code:
    man grep | grep "end options"
    preferably case insensitive search
    M Abu Rahmeh
    ‘—so long as I get somewhere,’ Alice added as an explanation.
    ‘Oh, you’re sure to do that,’ said the Cat, ‘if you only walk long enough.’

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: how to make grep ignore special characters

    Code:
     man grep | grep -i -A 3 -- "--IgnorE-CasE"

  5. #5
    Join Date
    Jun 2007
    Location
    North Cyprus
    Beans
    19
    Distro
    Ubuntu

    Re: how to make grep ignore special characters

    I hope this will work:

    man userdel | grep '\-r'

  6. #6
    Join Date
    Apr 2008
    Location
    /jordan.d
    Beans
    137

    Re: how to make grep ignore special characters

    thx guys..u rock
    M Abu Rahmeh
    ‘—so long as I get somewhere,’ Alice added as an explanation.
    ‘Oh, you’re sure to do that,’ said the Cat, ‘if you only walk long enough.’

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •