1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Find a word in a lot txt files

Discussion in 'General Software' started by GSquadron, May 11, 2011.

  1. GSquadron

    GSquadron

    Joined:
    Dec 2, 2009
    Messages:
    3,264 (1.28/day)
    Thanks Received:
    316
    Hi guys!
    Is there a way to find a specific word in a lot of txt files?
    I have like 200 files and it takes me a lot of time to find the word in the files
    I need to find a command inside the txt files as quickly as possible
    Is there a program to find the word inside all of the 200 txt files? :wtf:
     
  2. Yukikaze

    Yukikaze

    Joined:
    Sep 24, 2008
    Messages:
    2,375 (0.79/day)
    Thanks Received:
    526
    Location:
    Hillsboro, Oregon, USA
    yogurt_21 and GSquadron say thanks.
  3. W1zzard

    W1zzard Administrator Staff Member

    Joined:
    May 14, 2004
    Messages:
    16,541 (3.61/day)
    Thanks Received:
    15,653
    +1 for grep
     
    cheesy999 says thanks.
    10 Year Member at TPU
  4. Wrigleyvillain

    Wrigleyvillain PTFO or GTFO

    Joined:
    Oct 13, 2007
    Messages:
    7,704 (2.31/day)
    Thanks Received:
    1,791
    Location:
    Chicago
    Yes this is a perfect example of something *nix can do better than any...
     
  5. RejZoR

    RejZoR

    Joined:
    Oct 2, 2004
    Messages:
    9,578 (2.15/day)
    Thanks Received:
    3,803
    Location:
    Europe/Slovenia
    Erm, has anyone of you ever used Windows search? Just check the option to actually scan the content of files and it will look into all of them. It's even easier if it's plaintext...
     
    10 Year Member at TPU
  6. DanTheBanjoman Señor Moderator

    Joined:
    May 20, 2004
    Messages:
    10,546 (2.30/day)
    Thanks Received:
    1,384
    Or you can just use the Windows search function. Look under indexing options > advanced > file types > and have windows index file contents for txt files.
     
    cheesy999 says thanks.
    10 Year Member at TPU
  7. digibucc

    digibucc

    Joined:
    May 21, 2009
    Messages:
    4,966 (1.80/day)
    Thanks Received:
    1,519
    it's a horrible example of that. it's a better example of people assuming
    linux can do something better, without having the complete knowledge to
    know it's a function available in most operating systems.
     
  8. W1zzard

    W1zzard Administrator Staff Member

    Joined:
    May 14, 2004
    Messages:
    16,541 (3.61/day)
    Thanks Received:
    15,653
    does windows search speak regexp ?
     
    cheesy999 says thanks.
    10 Year Member at TPU
  9. digibucc

    digibucc

    Joined:
    May 21, 2009
    Messages:
    4,966 (1.80/day)
    Thanks Received:
    1,519
    fair enough, for regular expressions grep is needed, but was that the question?
    i highly doubt that was what he was specifically referring to when he said nix can do better...

    edit: grep isn't needed, other tools can do it. but windows native search cannot.
     
  10. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    18,942 (6.37/day)
    Thanks Received:
    8,189
    Location:
    IA, USA
    I'd use EditPlus. It has a "Find in files..." feature which can even search binaries (executables, DLLs, etc.) for a string. Last I checked, you can use it for free--you'll just get a nag screen popping up everytime you start it.
     
    cheesy999 says thanks.
    Crunching for Team TPU
  11. Easy Rhino

    Easy Rhino Linux Advocate

    Joined:
    Nov 13, 2006
    Messages:
    14,301 (3.89/day)
    Thanks Received:
    4,196
    i know i am going off topic but wouldnt it also be true that given the same system specs grep would find a specific word in 200+ txt files much faster than windows indexer? i mean, come on.
     
    cheesy999 says thanks.
    10 Year Member at TPU
  12. cheesy999

    Joined:
    Jul 2, 2010
    Messages:
    4,028 (1.72/day)
    Thanks Received:
    629
    Location:
    UK
    Its 200txt files -how long do you think that takes?
     
  13. erocker

    erocker Super Moderator Staff Member

    Joined:
    Jul 19, 2006
    Messages:
    41,643 (10.98/day)
    Thanks Received:
    17,144
    In notepad or wordpad I use ctrl+f, enter value and search. I'm not sure if we're talking about different things or not?
     
    cheesy999 says thanks.
    10 Year Member at TPU
  14. cheesy999

    Joined:
    Jul 2, 2010
    Messages:
    4,028 (1.72/day)
    Thanks Received:
    629
    Location:
    UK
    not unless controlf works with all 200 txt files at the same time (imagines going through them one at a time:banghead:)
     
  15. Easy Rhino

    Easy Rhino Linux Advocate

    Joined:
    Nov 13, 2006
    Messages:
    14,301 (3.89/day)
    Thanks Received:
    4,196
    beats me. but it is faster using grep. what's more, in a business if you were scan through tens of thousands of documents the time saved would really add up. just saying.

    the OP has a bunch of txt files and he is trying to avoid doing what you suggested because it takes forever when youve got a bunch of files.
     
    cheesy999 says thanks.
    10 Year Member at TPU
  16. erocker

    erocker Super Moderator Staff Member

    Joined:
    Jul 19, 2006
    Messages:
    41,643 (10.98/day)
    Thanks Received:
    17,144
    Yeah, the 200 files at once kinda went over my head. I'm going to try grep as this could be really handy for work.
     
    cheesy999 says thanks.
    10 Year Member at TPU
  17. DanTheBanjoman Señor Moderator

    Joined:
    May 20, 2004
    Messages:
    10,546 (2.30/day)
    Thanks Received:
    1,384
    Does grep speak Klingon? I don't see how any of those questions matter for this purpose.
     
    10 Year Member at TPU
  18. W1zzard

    W1zzard Administrator Staff Member

    Joined:
    May 14, 2004
    Messages:
    16,541 (3.61/day)
    Thanks Received:
    15,653
    grep -i -e "hab.*sosll\s+quch" klingonopera.txt ?
     
    10 Year Member at TPU
  19. FordGT90Concept

    FordGT90Concept "I go fast!1!11!1!"

    Joined:
    Oct 13, 2008
    Messages:
    18,942 (6.37/day)
    Thanks Received:
    8,189
    Location:
    IA, USA
    If they aren't huge, less than a second.


    Example (each line is "path"(line#,column#):line that contains the searched string):
    [​IMG]
    139 KiB (143,258 bytes) in 91 files searched over gigabit LAN.

    Double click on one of them to open just that document in EditPlus. Right-click and select "Open All" to open them all in EditPlus. If you do Open All, you can then perform a replace on "all open documents" if that is what you want. EditPlus doesn't freak out at opening large files like Notepad does.
     
    Last edited: May 11, 2011
    cheesy999 says thanks.
    Crunching for Team TPU
  20. de.das.dude

    de.das.dude Pro Indian Modder

    Joined:
    Jun 13, 2010
    Messages:
    8,095 (3.42/day)
    Thanks Received:
    2,215
    Location:
    Pune
    i think in qindows there is something called search in content. so if you create a folder and put all the to be searched files there, then you can use this technique.
     

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)