Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
I use the following command to search for files that contain certain words Code: grep "Due Mtg" *.php but, i cant seach the sub directory I have to go into ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234

    Search command


    I use the following command to search for files that contain certain words
    Code:
    grep "Due Mtg" *.php
    but, i cant seach the sub directory
    I have to go into the directory and type the command again.

    is that any shorter way to do it?
    Proper Planing is a way of success

  2. #2
    Banned
    Join Date
    Jul 2004
    Posts
    947
    as root
    Code:
    find / -iname foo
    where / can be any dir

    and foo is what you are searching for

  3. #3
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234
    Quote Originally Posted by the_guy_dressed_in_black
    as root
    Code:
    find / -iname foo
    where / can be any dir

    and foo is what you are searching for
    I dont have the root permission
    Proper Planing is a way of success

  4. #4
    Linux Engineer spencerf's Avatar
    Join Date
    Jan 2005
    Location
    Syracuse, NY
    Posts
    1,144
    well then only seach in directories you have permission

    for example

    find /home/jack/ -iname foo
    All right, brain. You don't like me and I don't like you, but let's just do this and I can get back to killing you with beer. All New Users Read This!!! If you have a grub problem please look at GRUB MANUAL

  5. #5
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234
    Quote Originally Posted by spencerf
    well then only seach in directories you have permission

    for example

    find /home/jack/ -iname foo
    but i dont know where the file is exist i cant get the expected result by typing the following command at the directory where i have permission
    Code:
    find / -iname "TcpServer"
    Proper Planing is a way of success

  6. #6
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Let's say that your PHP files are all stored in /home/user/php/ . To find the line that you're looking for, you could do:
    Code:
    find /home/user/php/ -iname '*.php' -exec grep -H 'TcpServer' '{}' \;
    "What the hell is that?", you're asking.

    Well, it basically looks for every file in the directory you gave it AND ALL SUBDIRECTORIES THEREOF, and then executes "grep -H 'TcpServer' FILENAME" on each one. It will print out the name of each file that contains your string.

  7. #7
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234
    Quote Originally Posted by Cabhan
    Let's say that your PHP files are all stored in /home/user/php/ . To find the line that you're looking for, you could do:
    Code:
    find /home/user/php/ -iname '*.php' -exec grep -H 'TcpServer' '{}' \;
    "What the hell is that?", you're asking.

    Well, it basically looks for every file in the directory you gave it AND ALL SUBDIRECTORIES THEREOF, and then executes "grep -H 'TcpServer' FILENAME" on each one. It will print out the name of each file that contains your string.
    There are the command that i had type and the error that i get
    Code:
    msg@send-connect:~/apache/htdocs/exc$ find  -iname '*.php' -exec grep -H 'TcpServer' '{}' find: missing argument to `-exec'
    Proper Planing is a way of success

  8. #8
    Banned
    Join Date
    Jul 2004
    Posts
    947
    try it not being root, dont think it will returrn much

    Code:
     find / -iname foo

  9. #9
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234
    Quote Originally Posted by the_guy_dressed_in_black
    try it not being root, dont think it will returrn much

    Code:
     find / -iname foo
    Almost all the result that i get is "Permission denied"
    Proper Planing is a way of success

  10. #10
    Banned
    Join Date
    Jul 2004
    Posts
    947
    Quote Originally Posted by thcc2
    Quote Originally Posted by the_guy_dressed_in_black
    try it not being root, dont think it will returrn much

    Code:
     find / -iname foo
    Almost all the result that i get is "Permission denied"
    thats what i thought would happen
    could you not ask the admin to enter the root paaswd

Page 1 of 2 1 2 LastLast

Posting Permissions

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