Results 1 to 4 of 4

Thread: Ubuntu Command line - search all files for a particular string

  1. #1
    Join Date
    Aug 2008
    Beans
    7

    Ubuntu Command line - search all files for a particular string

    Hello all

    Using the terminal I am trying to search all files for a particular string

    This is my attempt

    find . -iname "*" -print0 | xargs -0 cat | grep "208.122.23.2" | >> ~/Documents/searchres

    Now this works BUT it is missing one quite important detail, and that is the filename

    How would I include this in my output please?

  2. #2
    Join Date
    Jul 2005
    Beans
    2,050

    Re: Ubuntu Command line - search all files for a particular string

    How about:

    Code:
    find . -exec grep -Hn 208.122.23.2 {} \;

  3. #3
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    Re: Ubuntu Command line - search all files for a particular string

    Code:
    grep '208.122.23.2' *
    edit: if you want line numbers
    Code:
    grep -n '208.122.23.2' *
    Last edited by HiImTye; June 4th, 2013 at 06:30 AM.

  4. #4
    Join Date
    Jun 2006
    Location
    Brisbane Australia
    Beans
    713

    Re: Ubuntu Command line - search all files for a particular string

    Code:
    grep -rF 208.122.23.2
    is the answer.

Tags for this Thread

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
  •