The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

i want find a words in file

Discussion in 'General Discussion' started by moalim, Dec 25, 2003.

  1. moalim

    moalim Active Member

    Joined:
    Jun 24, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    HI

    how can i find a words in file for SSH COMMANDS


    example:
    -------
    cat /home/*/public_html /*. php
    -------
    this command find all php's files on server

    i want find words in files too


    THANKS
     
    #1 moalim, Dec 25, 2003
    Last edited: Dec 25, 2003
  2. kris1351

    kris1351 Well-Known Member

    Joined:
    Apr 18, 2003
    Messages:
    963
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Lewisville, Tx
    You can do grep <word> <file> and this will search for a particular word or string in a file. grep -i ignores the case of lettering.
     
  3. moalim

    moalim Active Member

    Joined:
    Jun 24, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    ok

    i was typed

    ----------------
    root@server7 [~]# Gerp "ner" *.php
    -bash: Gerp: command not found
    root@server7 [~]#
    ----------

    where is rong ?
     
  4. kris1351

    kris1351 Well-Known Member

    Joined:
    Apr 18, 2003
    Messages:
    963
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Lewisville, Tx
    ----------------
    root@server7 [~]# Gerp "ner" *.php
    -bash: Gerp: command not found
    root@server7 [~]#


    should be grep ner *.php instead of Gerp.

    or it could be

    grep -i ner *.php
     
  5. moalim

    moalim Active Member

    Joined:
    Jun 24, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    :eek:

    root@server7 [~]# grep ner *.php
    grep: *.php: No such file or directory
    root@server7 [~]# grep -i ner *.php
    grep: *.php: No such file or directory
     
  6. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    if you want to search files in directories below the current directory then use grep -r ner *.php.

    It will search recursively
     
  7. moalim

    moalim Active Member

    Joined:
    Jun 24, 2003
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    i want to search words in PHP files in HOME directory


    +++++
    root@server7 [/home]# Gerp "ner" *.php
    -bash: Gerp: command not found
    root@server7 [/home]# grep ner *.php
    grep: *.php: No such file or directory
    root@server7 [/home]# grep -r ner *.php.
    grep: *.php.: No such file or directory
    root@server7 [/home]# grep -r ner *.php
    grep: *.php: No such file or directory


    +++++
    THANKS ALOT FOR HELP ME
     
  8. asmithjr

    asmithjr Well-Known Member

    Joined:
    Jun 13, 2003
    Messages:
    475
    Likes Received:
    1
    Trophy Points:
    18
    sounds like you do not have any php files in the directory you are running the command from.

    cd /home

    grep -r word *

    where word is the word you want to find.
     
Loading...

Share This Page