Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, I'd like to mix 2 commands but I don't know how to do this... $> locate mysql -> to find all files matching with "mysql" and $> cat (of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2005
    Posts
    12

    cat of pre-selected files


    Hi,

    I'd like to mix 2 commands but I don't know how to do this...
    $> locate mysql
    -> to find all files matching with "mysql"
    and
    $> cat (of the files above) | grep datadir
    -> to show the files that contain "datadir" among the files above

    It might be a pipe but I don't know where to put it...

    Thanks

  2. #2
    Linux Guru
    Join Date
    Mar 2003
    Location
    Wisconsin
    Posts
    1,907
    How about:

    Code:
    locate mysql | grep datadir
    Jeremy
    Registered Linux user #346571
    "All The Dude ever wanted was his rug back" - The Dude

  3. #3
    Just Joined!
    Join Date
    Mar 2005
    Posts
    12
    no, what I would like to do is :
    to find all files which file path or name contain "mysql" and file contain the "datadir" string inside.

    N.B: You gave me the way to find all files which contain "mysql" and "datadir" in their file path or name.

  4. #4
    Just Joined!
    Join Date
    Sep 2004
    Posts
    12
    Code:
    for i in $(locate mysql) ; do grep -H "datadir" ; done
    The "-H" option is to specify the file name you are searching inside

Posting Permissions

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