Find the answer to your Linux question:
Results 1 to 6 of 6
Hi I was wondering if this is the correct command when I want to do 'grep' on multiple files in the same folder cat 1.txt | cat 2.txt | cat ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    3

    What's the linux command to do 'grep' on multiple file????


    Hi I was wondering if this is the correct command when I want to do 'grep' on multiple files in the same folder

    cat 1.txt | cat 2.txt | cat 3.txt |cat 4.txt |grep text

    Thanks!

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,461
    no.
    but grep can do it natively, and even recursive
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Oct 2011
    Posts
    3
    but this code can still perform the function I need right? if not can you please let me know the correct command?? Thanks!

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,461
    No, your approach would only grep in 4.txt.

    You can probably figure out the correct command yourself.
    Hint: You only need grep and your four txt files.

    Code:
    man grep
    You must always face the curtain with a bow.

  6. #5
    Just Joined!
    Join Date
    Oct 2011
    Posts
    3
    Thank you!

    I change the command to cat 1.txt 2.txt 3.txt 4.txt |grep text

  7. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,461
    You dont need cat
    You must always face the curtain with a bow.

Posting Permissions

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