Find the answer to your Linux question:
Results 1 to 2 of 2
I want to search multiple files in multiple directories for the content "language" within the file. For example, find all files on the server named "index.php" which have the content ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    1

    Cool Searching File Contents

    I want to search multiple files in multiple directories for the content "language" within the file.

    For example, find all files on the server named "index.php" which have the content "language" within the php file. Thanks.

    I found the following command: 'grep -r "language" *' However, this only searches the directory you are in, and no subdirectories.

    It will also need to show the (absolute) path of the files which contain 'language'

  2. #2
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    The "-R" option means recursively, so it will search all other subdirectories:
    Code:
    alex@danu ~/test/bash $ grep -lR foo *
    test_dir/file
    test_dir/subdir/file
    "-l" just means "don't print the line that matched, just tell me the name of the file."

    Hope that helps!
    DISTRO=Arch
    Registered Linux User #388732

Posting Permissions

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