• Login
Community
  • Login

Suggestion: Find in Files from command line

Scheduled Pinned Locked Moved General Discussion
35 Posts 12 Posters 9.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A
    Alan Kilborn @Vitaliy Dovgan
    last edited by Sep 27, 2021, 11:58 AM

    @Vitaliy-Dovgan said in Suggestion: Find in Files from command line:

    The already existing solutions for searching in files

    Well, I think in reality that list is going to be a bit of a long one.

    Another one for the list is PowerGREP . It’s certainly not “free”, but I don’t know if a list of these types of alternatives should only list free programs?

    Actually, I don’t use PowerGREP any longer. What I’ve found is that RegexBuddy (also not free) has a little “grepper” built into it that is very capable and produces output much like Notepad++'s Search results window. No command line options, though, but in truth, I don’t think I’ve ever had a need for such a thing.

    E 1 Reply Last reply Sep 28, 2021, 8:08 PM Reply Quote 1
    • E
      Ekopalypse @Alan Kilborn
      last edited by Sep 28, 2021, 8:08 PM

      @Alan-Kilborn

      I’m using Filelocator Lite, which is now called AgentRansack . Nice, but something built into Npp might make me uninstall it.

      1 Reply Last reply Reply Quote 1
      • M
        Michael Vincent @Vitaliy Dovgan
        last edited by Sep 28, 2021, 8:22 PM

        @Vitaliy-Dovgan said in Suggestion: Find in Files from command line:

        The already existing solutions for searching in files are:

        AstroGrep ( http://astrogrep.sourceforge.net/ ) - only searching, no replacing, wide command line arguments
        Searcher ( https://sourceforge.net/projects/searcher/ ) - only searching, no replacing, no command line arguments
        Text Crawler ( https://www.digitalvolcano.co.uk/textcrawler.html ) - searching & replacing, wide command line arguments

        @Alan-Kilborn

        Another one for the list is PowerGREP.

        @Ekopalypse

        I’m using Filelocator Lite

        Am I the only one using good old command line grep?

        Cheers.

        E 1 Reply Last reply Sep 28, 2021, 8:25 PM Reply Quote 0
        • E
          Ekopalypse @Michael Vincent
          last edited by Sep 28, 2021, 8:25 PM

          @Michael-Vincent

          ‘grep’ is not recognized as an internal or external command,
          operable program or batch file.

          ?? hmmm … maybe that is the reason why I’m not using it :-D

          P 1 Reply Last reply Sep 28, 2021, 8:36 PM Reply Quote 1
          • P
            PeterJones @Ekopalypse
            last edited by PeterJones Sep 28, 2021, 8:38 PM Sep 28, 2021, 8:36 PM

            @Michael-Vincent ,

            Am I the only one using good old command line grep?

            No. I personally use the old gnuwin32 grep , though it wouldn’t surprise me if there were more modern (or 64bit) versions ported to windows executables.

            @Ekopalypse (sorry for the snarky reply, but your phrasing required such)

            ‘grep’ is not recognized as an internal or external command,
            

            The same errors happen for me when I try to run an application on my PC that I haven’t installed – like, for instance, the FileLocator/AgentRansack that you mentioned:

            >where filelocator
            INFO: Could not find files for the given pattern(s).
            
            >where agentransack
            INFO: Could not find files for the given pattern(s).
            
            >filelocator
            'filelocator' is not recognized as an internal or external command,
            operable program or batch file.
            
            >agentransack
            'agentransack' is not recognized as an internal or external command,
            operable program or batch file.
            
            >where grep
            C:\usr\local\bin\grep.exe
            
            >grep --version
            GNU grep 2.5.4
            
            Copyright (C) 2009 Free Software Foundation, Inc.
            License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
            This is free software: you are free to change and redistribute it.
            There is NO WARRANTY, to the extent permitted by law.
            

            maybe that is the reason why I’m not using it :-D

            That’s not likely the reason, because it’s as easy (or easier) to install gnuwin32 grep as it is to install the FileLocator/AgentRansack.

            M 1 Reply Last reply Sep 28, 2021, 8:41 PM Reply Quote 1
            • E
              Ekopalypse
              last edited by Ekopalypse Sep 28, 2021, 8:38 PM Sep 28, 2021, 8:38 PM

              Ahh - I had understood that this was a system tool.

              P 1 Reply Last reply Sep 28, 2021, 8:45 PM Reply Quote 1
              • M
                Michael Vincent @PeterJones
                last edited by Sep 28, 2021, 8:41 PM

                @PeterJones
                @Ekopalypse

                I have grep.exe installed in my C:\usr\bin\ directory along with Git for Windows (which supplies it’s own grep), but I prefer the GnuWin32 version.

                Cheers.

                1 Reply Last reply Reply Quote 1
                • P
                  PeterJones @Ekopalypse
                  last edited by Sep 28, 2021, 8:45 PM

                  Personally, I tend to keep my command line and GUI programs separate. I’ll let a GUI program like Notepad++ do what it’s good at, and a command-line tool like grep do what it’s good at. If I want command-line power, I use a command-line tool (and usually something written originally for linux and ported to windows); when I want a graphical environment, I use a native win32 application.

                  Thus, if I’ve already got one of the files I want to search open in Notepad++, I will pull up the Find In Files and have it recursively search the directory structure relative to the current file. But if I have something I’m trying to find elsewhere (more often the case), or if I want a lot of fine control on command-line-style arguments, I’m more likely to pull out grep. (which explains why I’m not likely to use the -ff... args that Vitaly suggested.

                  But I can see for someone who prefers to always use a GUI for their grepping results, whether started from the GUI or from the command line, I could see the benefit of having that grepping be part of Notepad++ rather than having a specialty GUI app like those mentioned by others.

                  1 Reply Last reply Reply Quote 1
                  • A
                    Alan Kilborn
                    last edited by Alan Kilborn Sep 28, 2021, 8:55 PM Sep 28, 2021, 8:54 PM

                    …but something built into Npp might make me uninstall it.

                    I think we’re overlooking something.
                    Notepad++ isn’t a great searching tool.
                    There, I’ve said it. :-)
                    I await the flames.

                    E 1 Reply Last reply Sep 28, 2021, 9:02 PM Reply Quote 1
                    • A
                      Alan Kilborn
                      last edited by Alan Kilborn Sep 28, 2021, 9:03 PM Sep 28, 2021, 9:00 PM

                      …grep…

                      Maybe grep isn’t great for multiple directories that aren’t in the same tree? Too much to specify, or maybe there’s a nice way to do something like that via a config file?

                      Specifying such a thing is problematic even for the best tools.
                      It is a weakness for Notepad++ as well.

                      Plus grep uses yare (yet another regex engine).
                      The grepper in RegexBuddy allows me to pick the regex engine I want to use (typically I set it to the same one as N++, i.e., Boost).

                      <start_unpaid_commercial>
                      RegexBuddy really is a great value, for I think 35USD.
                      </end_upaid_commercial>

                      1 Reply Last reply Reply Quote 0
                      • E
                        Ekopalypse @Alan Kilborn
                        last edited by Sep 28, 2021, 9:02 PM

                        @Alan-Kilborn - to quote the famous “how dare are you??” :-D

                        To be honest, I never had a problem with it. Yes, there are better solutions, like the one I posted, but for what I use it for, it’s good enough. Maybe because I only use utf8 encoded files.

                        A 1 Reply Last reply Sep 28, 2021, 9:06 PM Reply Quote 0
                        • A
                          Alan Kilborn @Ekopalypse
                          last edited by Alan Kilborn Sep 28, 2021, 9:07 PM Sep 28, 2021, 9:06 PM

                          @Ekopalypse said in Suggestion: Find in Files from command line:

                          how dare are you?

                          :-)

                          N++'s searching is slow, and as previously mentioned, how does one search several different trees? Also, you can’t do anything else with it while it is conducting a search.

                          It’s perfectly fine for most things (interactive find-next, find all in current file, …), but when you get into searching a lot of files, well there are other and better ways to skin that cat.

                          And since that is what the beginning of this thread was about (automating an already not-great feature), I say “meh” to the original idea. Not something I’d use. But I respect those that would, and their opinions on the topic.

                          E 1 Reply Last reply Sep 28, 2021, 9:08 PM Reply Quote 1
                          • E
                            Ekopalypse @Alan Kilborn
                            last edited by Sep 28, 2021, 9:08 PM

                            @Alan-Kilborn

                            The idea is great, because then I can start a new instance easily and it is not blocking my current instance.

                            A 1 Reply Last reply Sep 28, 2021, 9:10 PM Reply Quote 0
                            • A
                              Alan Kilborn @Ekopalypse
                              last edited by Sep 28, 2021, 9:10 PM

                              @Ekopalypse said in Suggestion: Find in Files from command line:

                              The idea is great, because then I can start a new instance easily and it is not blocking my current instance.

                              If I’m considering “calling out” like that, I’ll call out to a more capable searching program. :-)
                              And when that more-capable program shows me the hits and I want to go to one of them, I’ll have that program call back into Notepad++ to take me to the file and hit line.

                              E 1 Reply Last reply Sep 28, 2021, 9:19 PM Reply Quote 0
                              • E
                                Ekopalypse @Alan Kilborn
                                last edited by Sep 28, 2021, 9:19 PM

                                @Alan-Kilborn

                                I’m not sure I understand, but in the end it depends on personal preference anyway.
                                I mean, if I use Npp because of its search function, then I think I’m using the wrong tool for the job.
                                On the other hand, if I mainly edit, then it’s good to have a powerful search function like Npp has, and if it can be easily launched from Npp and doesn’t block me - all the better.

                                A 1 Reply Last reply Sep 29, 2021, 12:45 AM Reply Quote 2
                                • A
                                  Alan Kilborn @Ekopalypse
                                  last edited by Sep 29, 2021, 12:45 AM

                                  @Ekopalypse

                                  Well, in theory we could put together all we know and create the desired functionality via scripting…if it isn’t picked up natively. There’d be a lot of individual pieces, but I can’t think of anything that would be a “stopper”.

                                  E 1 Reply Last reply Sep 29, 2021, 8:20 AM Reply Quote 1
                                  • E
                                    Ekopalypse @Alan Kilborn
                                    last edited by Sep 29, 2021, 8:20 AM

                                    @Alan-Kilborn

                                    Yes, that (usually) always works :-D

                                    A 1 Reply Last reply Sep 29, 2021, 11:50 AM Reply Quote 1
                                    • A
                                      Alan Kilborn @Ekopalypse
                                      last edited by Sep 29, 2021, 11:50 AM

                                      @Ekopalypse

                                      And some of the pieces are:

                                      • invoke new instance of N++ with new parameters on the command line
                                      • command line pickoff of parameters (@Ekopalypse has showed us how to do this in the past)
                                      • invoking of the Find in Files dialog after N++ startup
                                      • filling in the fields on Find in Files with command line data
                                      • starting the Find in Files running

                                      So, okay, only 4 basic steps, but some of those steps have a lot of “meat” to them.

                                      I don’t know that I have sufficient interest in the base topic to work up a script, but the script-writer in me thinks that writing it would be more fun than using it would be useful. :-)

                                      1 Reply Last reply Reply Quote 2
                                      • A
                                        artie-finkelstein
                                        last edited by Sep 30, 2021, 11:39 PM

                                        YAREST (Yet Another Regular Expression Search Tool)

                                        I use grepWin from Stefans Tools .

                                        It’s FOSS, it’s also available in the PortableApps.com platform, it uses Boost (or plain text) for searching, it can be easily configured to invoke Npp at the desired found line [ grepWin :: Settings > Editor ]:

                                        C:\programs\Notepad++\notepad++.exe -n%line% "%path%"
                                        

                                        it works well as a Run menu command:

                                        <Command name="grepWin" Ctrl="no" Alt="no" Shift="no" Key="0">grepWin /searchpath:&quot;$(CURRENT_DIRECTORY)&quot; /filemask:&quot;*.*&quot;</Command>
                                        

                                        and I find it nicely bridges the CL/GUI divide. It took a very small amount of work (a batch file wrapper) to make it assume folder and file extension defaults as I prefer them for regular CL invocations. [But sometimes I’ll still fire up GnuWin32 grep (for one thing it’s less to type <grin>)]

                                        A 1 Reply Last reply Oct 4, 2021, 7:02 PM Reply Quote 2
                                        • A
                                          Alan Kilborn @artie-finkelstein
                                          last edited by Oct 4, 2021, 7:02 PM

                                          @artie-finkelstein said in Suggestion: Find in Files from command line:

                                          grepWin…it uses Boost

                                          That it uses Boost’s regex engine is a bit obscure – it doesn’t seem to advertise that – is a definite plus for N++ users that are used to it for searching.

                                          A 1 Reply Last reply Oct 7, 2021, 12:23 AM Reply Quote 0
                                          14 out of 35
                                          • First post
                                            14/35
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors