pfind command line for advanced search?

New to Puppy and have questions? Start here

Moderator: Forum moderators

Post Reply
miltonx
Posts: 156
Joined: Sat Nov 28, 2020 12:04 am
Has thanked: 11 times
Been thanked: 6 times

pfind command line for advanced search?

Post by miltonx »

Pfind advanced option is able to find files which contain certain strings. However, inputting directories and keywords in the gui is not time-efficient. Does pfind come with command line options for such advanced searche? Alternatively, is it possible to pipe grep command results to the pfind gui? I'm asking this because I hope I can search for files by command BUT view/edit/open the found files in pfind's window (or maybe some other gui such as rox-filer's find window, etc.)

User avatar
MochiMoppel
Posts: 1130
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 18 times
Been thanked: 366 times

Re: pfind command line for advanced search?

Post by MochiMoppel »

miltonx wrote:

Does pfind come with command line options for such advanced searche?

You can use pfind -d [DIR] to open Pfind with a specific directory preselected. Apart from this I don't know.

Alternatively, is it possible to pipe grep command results to the pfind gui?

Certainly not. Would this make sense? If you already have the grep results, why feed them to another search engine?

I'm asking this because I hope I can search for files by command BUT view/edit/open the found files in pfind's window (or maybe some other gui such as rox-filer's find window, etc.)

I don't know a meaningful combination of CLI grep and GUI "processor" of grep results. Why not use a GUI frontend for grep in the first place?

Pfind: Can search for text in files but is awfully slow. It will result only in file names but will not show the lines containing your search string. On the other hand Pfind provides many options to open/show/process the search results.

MMview: Sorry to mention my own creation. I did this out of frustration with Pfind. My aim was speed. You can view the found text and in the status bar you can also view the grep command used. See more explanation in Update 2020-04-10 post.

Geany: Contains a powerful (and probably little known) text search function (Menu Search -> Find in Files). It is fast and the found text lines are listed in the Messages window. Clicking on such a result line will open the file in a new tab and jump to respective line, ready to be edited. With a bit of ingenuity you can also open the file in ROX-Filer.

miltonx
Posts: 156
Joined: Sat Nov 28, 2020 12:04 am
Has thanked: 11 times
Been thanked: 6 times

Re: pfind command line for advanced search?

Post by miltonx »

MochiMoppel wrote: Mon Mar 22, 2021 1:59 am

Why not use a GUI frontend for grep in the first place?

Pfind: Can search for text in files but is awfully slow. It will result only in file names but will not show the lines containing your search string. On the other hand Pfind provides many options to open/show/process the search results.

MMview: Sorry to mention my own creation. I did this out of frustration with Pfind. My aim was speed. You can view the found text and in the status bar you can also view the grep command used. See more explanation in Update 2020-04-10 post.

Geany: Contains a powerful (and probably little known) text search function (Menu Search -> Find in Files). It is fast and the found text lines are listed in the Messages window. Clicking on such a result line will open the file in a new tab and jump to respective line, ready to be edited. With a bit of ingenuity you can also open the file in ROX-Filer.

I prefer to use command to grep things because I do a lot of repetitive searching and wish to be as fast as possible, say, copy an id number from my browser and then press a keybind to execute grep using the id number in clipboard, to find relevant files in my work folder, after which I hope a window will pop up showing all the found files in my work folder, having facilities of open/edit/rename etc. like pfind, so that I can quickly click to view or edit.

I will look up MMview and Geany to see if they fit. Thanks!

User avatar
foxpup
Posts: 186
Joined: Fri Jul 24, 2020 1:23 pm
Location: Europe near the Northsea
Has thanked: 75 times
Been thanked: 32 times

Re: pfind command line for advanced search?

Post by foxpup »

There is also the command find.
A simple example:

Code: Select all

find /root/.config/autostart -type f -name '*.desktop' -exec rox {} \;

Alternatively, works but not better ;-) :

Code: Select all

find /root/.config/autostart -type f | grep .desktop  | sed "s/^/rox /" | sh
Clarity
Posts: 3341
Joined: Fri Jul 24, 2020 10:59 pm
Has thanked: 1377 times
Been thanked: 443 times

Re: pfind command line for advanced search?

Post by Clarity »

mlocate/locate/updatedb changes file searches from many seconds on large filesystems to "instantly" when this is turn on.

Thus when in your system, the "find ..." give instant results vs having to wait for your answer.

This, old technology, is sometimes overlooked or missed.

User avatar
foxpup
Posts: 186
Joined: Fri Jul 24, 2020 1:23 pm
Location: Europe near the Northsea
Has thanked: 75 times
Been thanked: 32 times

Re: pfind command line for advanced search?

Post by foxpup »

I realized that maybe you want more.
Do you want to look for files with "some content" and use the filename?
Then you can use grep with the -l option.

Code: Select all

grep -iRl "some content" /somedir

The -R option is usefull to look recursively into directories.
Look in the man page of grep.

For more flexibility you could combine find and grep -l.
First you let find look for the right kind of files (e.g. desktop files) and then you keep those containing "some content" with grep -l
The result you could pipe.

Code: Select all

find /somedir -type f -name '*.desktop' -exec grep -l "some content" {} \; | sed "s/^/rox /" | sh

I have not tried this, but you get the idea.

User avatar
666philb
Posts: 429
Joined: Thu Jul 09, 2020 3:18 pm
Location: wales uk
Has thanked: 111 times
Been thanked: 146 times

Re: pfind command line for advanced search?

Post by 666philb »

MochiMoppel wrote: Mon Mar 22, 2021 1:59 am

Geany: Contains a powerful (and probably little known) text search function (Menu Search -> Find in Files). It is fast and the found text lines are listed in the Messages window. Clicking on such a result line will open the file in a new tab and jump to respective line, ready to be edited. With a bit of ingenuity you can also open the file in ROX-Filer.

i didn't know this .... thanks!!

User avatar
ThruHammer
Posts: 257
Joined: Sun Jul 12, 2020 1:08 am
Location: Ray Brook, NY
Been thanked: 14 times

Re: pfind command line for advanced search?

Post by ThruHammer »

Yeah, CRAZY! :ugeek: Leave it to Mochi. :thumbup2:

User avatar
cobaka
Posts: 521
Joined: Thu Jul 16, 2020 6:04 am
Location: Central Coast, NSW - au
Has thanked: 87 times
Been thanked: 49 times

Re: pfind command line for advanced search?

Post by cobaka »

This old technology is sometimes overlooked or missed.

At the beginning of my engagement with Linux I got a book, 'The Linux Command Line' by William Shotts.
At the beginning, he posed a question: Why use the command line?
His answer: "It's been said that a graphical used interface makes easy tasks easy, while [the] command line interface make difficult tasks possible."
He goes on - "This is still very true today".

Yes, I'm using old technology more and more - running Linux on hardware that most people would leave on the kerb-side for the trash collector.
Puppy Linux, using old technology, makes things possible that I never attempted using Windows - or sometimes attempted but gave up because the process was too slow.

cobaka

собака --> это Русский --> an old dog
"so-baka" (not "co", as in coast or crib).

miltonx
Posts: 156
Joined: Sat Nov 28, 2020 12:04 am
Has thanked: 11 times
Been thanked: 6 times

Re: pfind command line for advanced search?

Post by miltonx »

foxpup wrote: Mon Mar 22, 2021 12:51 pm

There is also the command find.
A simple example:

Code: Select all

find /root/.config/autostart -type f -name '*.desktop' -exec rox {} \;

Alternatively, works but not better ;-) :

Code: Select all

find /root/.config/autostart -type f | grep .desktop  | sed "s/^/rox /" | sh

This command opens the found file straight away. What I covet is the pfind GUI which lists the found files which can be conveniently renamed/deleted, etc. and shows the full path of each file.

User avatar
foxpup
Posts: 186
Joined: Fri Jul 24, 2020 1:23 pm
Location: Europe near the Northsea
Has thanked: 75 times
Been thanked: 32 times

Re: pfind command line for advanced search?

Post by foxpup »

miltonx wrote: Tue Mar 23, 2021 1:41 am

Code: Select all

find /root/.config/autostart -type f | grep .desktop  | sed "s/^/rox /" | sh

This command opens the found file straight away. What I covet is the pfind GUI which lists the found files which can be conveniently renamed/deleted, etc. and shows the full path of each file.

What you want to do with the files found is in the tail of the command.
You can replace rox with delete or rename ....
Leaving out the tail will only list the files.

Possibilities are endless with the command line to build up the command or script you want.
By the way, pfind (and filesearch) itself is a script.
I assume it will be difficult to beat it, unless for specific and/or easy tasks.

miltonx
Posts: 156
Joined: Sat Nov 28, 2020 12:04 am
Has thanked: 11 times
Been thanked: 6 times

Re: pfind command line for advanced search?

Post by miltonx »

foxpup wrote: Tue Mar 23, 2021 8:48 am
miltonx wrote: Tue Mar 23, 2021 1:41 am

Code: Select all

find /root/.config/autostart -type f | grep .desktop  | sed "s/^/rox /" | sh

This command opens the found file straight away. What I covet is the pfind GUI which lists the found files which can be conveniently renamed/deleted, etc. and shows the full path of each file.

What you want to do with the files found is in the tail of the command.
You can replace rox with delete or rename ....
Leaving out the tail will only list the files.

Possibilities are endless with the command line to build up the command or script you want.
By the way, pfind (and filesearch) itself is a script.
I assume it will be difficult to beat it, unless for specific and/or easy tasks.

I mean, I like that search result window which lists the found files, so that I can have an overall view of them, while also having the conveniency and flexibility to rename OR delete OR open some of them, depending on what I see. So the action cannot be hard coded in script.

I know this is a very tall demand. Now it seems probably no existing tool can achieve that.

miltonx
Posts: 156
Joined: Sat Nov 28, 2020 12:04 am
Has thanked: 11 times
Been thanked: 6 times

Re: pfind command line for advanced search?

Post by miltonx »

I found an imperfect workaround. The grep/find can be piped to sed, to add "rox -s " to the found file path, so each line becomes a command to show the file in rox window. By running that command, the rox -s parameter opens the directory and winks that file, though the wink is not long enough for my taste. (If rox has some parameter to select that file, it would be much better.)

However, this works only when a single file is found. If multiple files are found, several rox windows will open to show each found file. My eyes can only catch the last winking one.

User avatar
MochiMoppel
Posts: 1130
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 18 times
Been thanked: 366 times

Re: pfind command line for advanced search?

Post by MochiMoppel »

miltonx wrote:

I found an imperfect workaround

Methinks that this is the worst of all possible solutions. If your grep command finds 50 files you will open 50 ROX-Filer windows :shock:
There are still other solutions left but you seem so adamant to start grep from command line that you unnecessarily limit your choices to such obscure workarounds.

If opening ROX-Filer windows is what you find acceptable and only multiple matches pose a problems, then why don't you use ROX-Filer's search? You seem to like this function and we discussed it at great lenght here. At least you will deal with only one single result window and one single ROX-Filer window, no matter how many files were found by your grep command,. As a bonus you can let ROX "wink" as often as you wish.

miltonx
Posts: 156
Joined: Sat Nov 28, 2020 12:04 am
Has thanked: 11 times
Been thanked: 6 times

Re: pfind command line for advanced search?

Post by miltonx »

MochiMoppel wrote: Wed Mar 24, 2021 10:38 am
miltonx wrote:

I found an imperfect workaround

Methinks that this is the worst of all possible solutions. If your grep command finds 50 files you will open 50 ROX-Filer windows :shock:
There are still other solutions left but you seem so adamant to start grep from command line that you unnecessarily limit your choices to such obscure workarounds.

If opening ROX-Filer windows is what you find acceptable and only multiple matches pose a problems, then why don't you use ROX-Filer's search? You seem to like this function and we discussed it at great lenght here. At least you will deal with only one single result window and one single ROX-Filer window, no matter how many files were found by your grep command,. As a bonus you can let ROX "wink" as often as you wish.

I said that I do high frequency repetitive search in my daily work. These searches have a uniform pattern, and result in one or two files being found in my work folder. It is not a "deep" job, but a very tedious repetitive one. So reducing manual clicking and typing is the key for efficiency of my daily office job (instead of computer geek stuff). This is a special case, otherwise i wouldn't have started this thread. I am trying to find a tailored solution for a special use, and you are assuming I am stubborn enough to use this for all search situations. Of course I will not use this technique for other "normal" search tasks as the post you mentioned.

Post Reply

Return to “Beginners Help”