Find the answer to your Linux question:
Results 1 to 6 of 6
Hi all, may i know what is the command to seach files that contain certain string, for example get_Date in Linux?...
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

    find command


    Hi all,
    may i know what is the command to seach files that contain certain string, for example get_Date in Linux?
    Proper Planing is a way of success

  2. #2
    Linux User
    Join Date
    Jan 2005
    Location
    Florida
    Posts
    414
    If you are trying to find a text string use grep
    registered linux user: 387197

  3. #3
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234
    Quote Originally Posted by jimbaloo
    If you are trying to find a text string use grep
    grep follow by what?
    Proper Planing is a way of success

  4. #4
    Linux Guru smolloy's Avatar
    Join Date
    Apr 2005
    Location
    CA, but from N.Ireland
    Posts
    2,414
    If you wanna search FILE for STRING use,
    Code:
    grep STRING FILE
    As usual it's all in the man page,
    Code:
    man grep
    You should take your time to read the man files before posting.
    Registered Linux user #388328 || Registered LFS user #15880
    AMD 64 X2 4600+ :: 2X1GB DDR2 800 :: GeForce 9400 GT 512MB :: ASUS M2N32 Deluxe :: 4X250GB SATAII
    Need instant help? Try us on IRC -- #linuxforums on freenode

  5. #5
    Linux Newbie
    Join Date
    Dec 2005
    Location
    Singapore
    Posts
    234
    Quote Originally Posted by smolloy
    If you wanna search FILE for STRING use,
    Code:
    grep STRING FILE
    As usual it's all in the man page,
    Code:
    man grep
    You should take your time to read the man files before posting.
    thks
    Proper Planing is a way of success

  6. #6
    Linux Engineer
    Join Date
    Sep 2003
    Location
    Knoxhell, TN
    Posts
    1,078
    by the way, 'grep' comes from the ed command 'Global Regular Expression Print'

    you should read the manpage for regular expressions or buy a book such as "sed & awk" that covers regular expressions extensively.

    the syntax for grep is as follows:
    Code:
    grep &#91;options&#93; <regular expression> <file&#40;s&#41; to be searched>
    to find files by name, use find:
    Code:
    find <directory to start at> -iname <name to search for>
    it's a good idea to take advantage of shell globbing when using find. read the bash manpage and your shell's manpage (probably bash if you haven't changed it from the default.)
    Their code will be beautiful, even if their desks are buried in 3 feet of crap. - esr

Posting Permissions

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