LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   find command help needed (https://www.linuxquestions.org/questions/linux-newbie-8/find-command-help-needed-4175516787/)

theKbStockpiler 08-29-2014 03:06 PM

find command help needed
 
Hi, as I can not find a good guide on this I have these questions.

How is a search done with cli that will search for multiple and or partial strings in a file name? let's say I want to find a text file that has two different words or either one of two words and or partial pieces of these words. How is this done?

Thanks for your expertise!

Firerat 08-29-2014 03:32 PM

Hmm, a messy one

I think the -o flag will do it

Code:

man find
Since you don't give 'real' examples

Code:

find /path/ -name "*fo* -o -name "*ba*"
Would find

Poorbreifoobar
barofbadrequest
foobar
Wouldnotreturnthis


you need to provide a better brief ..

One or two words, or partial match?

when is a partial going to not match the full?

Oops of not or
Still .. need real example (input and desired output) to understand

evo2 08-29-2014 03:33 PM

Hi,


recursively search the current directory for files with "foo" or "bar" in their names:
Code:

find . -name '*foo*' -o -name '*bar*'
Evo2.

theKbStockpiler 08-29-2014 04:20 PM

Thanks for the help! I looked at both (man find) and find --help. Ugh!!!!

What I'm doing is creating a directory that is full of linux notes/guides and their links because I find myself with 100 browser windows open at once. The html pages are a pain so I'm just copy and pasting them to gedit. If I want to see the original guide/tutorial , I still have the link.

Lets say I'm creating text docs and some are titled (systemd\logging) and some are (rsyslogd\logging) because of the contents of the guide/tutorial. If I want to get some info on logging I don't have to remember about (sysemd logging) because a bash search command would bring it up. I think that this is a better solution than to have a bunch of folders because some of the text files would be in one or the other as in systemd or logging. I'm making my own linux guide data base in a way. Sometimes good webpages get removed and this way I still have most of the info that they contained.

Firerat 08-29-2014 04:33 PM

Hmm..

Web browser bookmarks?

And the man and info commands have always been usefull to me

I less understand the brief


Maybe you need

Code:

man -k mount
( as an example)



I don't understand what you want/need
your latest post had left me even more uncertain

theKbStockpiler 08-29-2014 08:52 PM

The asterisks and the Boolean Or did the the trick so I thank you both for that. To explain my purpose for this ,imagine you have so many text files in a directory; that you can't separate well into folders, and you want to find any and all text files you named with log in it. Examples are systemd-logging, LogGuides, linuxLogging. The find command and your advice cut down on manually sorting text files to consider.

Thanks this will help me a lot!

Firerat 08-30-2014 05:38 AM

ok, assuming many files in one directory

Code:

less /path/to/dir/*Log*

You can then use command sequence ":n" for next file ":p" for previous (no "")

man less

For more details on the many commands


All times are GMT -5. The time now is 04:40 PM.