Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    cat of pre-selected files


    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"
    $> 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...


  2. #2
    Linux Guru
    Join Date
    Mar 2003
    How about:

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

  3. #3
    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. $spacer_open
  5. #4
    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