Results 1 to 2 of 2

Thread: Search for file containing text

  1. #1
    Join Date
    Sep 2013
    Beans
    3

    Search for file containing text

    How do I search the whole hard drive for a file name, containing a certain text word? e.g. search for all "index.html" containing "xyzzy".

    I tried installing: "sudo apt-get install gnome-search-tool"

    The instructions then said, "Open Search for files select Select More Options"
    and I've no idea how to do that.

  2. #2
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Search for file containing text

    You don't need to install any special tools - the standard 'find' and 'grep' command line utilities will do that for you e.g.

    Code:
    find / -name 'index.html' -exec grep -H 'xyzzy' {} + 2>/dev/null
    The '2>/dev/null' is not essential, it just stops the output getting buried in lots of permission errors. If you think the file may be somewhere an ordinary user does not have read access you can run it with 'sudo'

    Code:
    sudo find / -name 'index.html' -exec grep -H 'xyzzy' {} +
    You can also make the grep case insensitive (-i) and/or restrict it to complete word matches (-w) - type man grep for more info

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
  •