Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14

Thread: Search command

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234

    Quote Originally Posted by the_guy_dressed_in_black
    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
    He will not do this i think, due to security reasons, he worry that the user will scan through the system :P
    Proper Planing is a way of success

  2. #12
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Quote Originally Posted by thcc2
    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'
    Your forgot the "\;" at the end of the command.

    The full command is:
    Code:
    find /home/user/php -iname '*.php' -exec grep -H 'TcpServer' '{}' \;

  3. #13
    Just Joined!
    Join Date
    Jan 2005
    Location
    3rd stone
    Posts
    4

    Re: Search command

    Quote Originally Posted by thcc2
    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?
    grep -R "Due Mtg" .

    grep recursively down the given directory (in this case . being the directory you are currently in) for "Due Mtg"

    The . can easily be replaced with any directory including /
    Of course -i ignores case if need be.

    // tony

  4. $spacer_open
    $spacer_close
  5. #14
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234

    Re: Search command

    Quote Originally Posted by amf57
    Quote Originally Posted by thcc2
    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?
    grep -R "Due Mtg" .

    grep recursively down the given directory (in this case . being the directory you are currently in) for "Due Mtg"

    The . can easily be replaced with any directory including /
    Of course -i ignores case if need be.

    // tony
    Thks, this is what i want
    Proper Planing is a way of success

Posting Permissions

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