LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-29-2014, 04:06 PM   #1
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: Fedora14,Scientific 6.1?, Mandriva 2010 ;GO MAGEIA!!!Next up Gentoo
Posts: 838

Rep: Reputation: 51
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!
 
Old 08-29-2014, 04:32 PM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
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

Last edited by Firerat; 08-29-2014 at 04:35 PM.
 
Old 08-29-2014, 04:33 PM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,


recursively search the current directory for files with "foo" or "bar" in their names:
Code:
find . -name '*foo*' -o -name '*bar*'
Evo2.
 
Old 08-29-2014, 05:20 PM   #4
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: Fedora14,Scientific 6.1?, Mandriva 2010 ;GO MAGEIA!!!Next up Gentoo
Posts: 838

Original Poster
Rep: Reputation: 51
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.
 
Old 08-29-2014, 05:33 PM   #5
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
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
 
Old 08-29-2014, 09:52 PM   #6
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: Fedora14,Scientific 6.1?, Mandriva 2010 ;GO MAGEIA!!!Next up Gentoo
Posts: 838

Original Poster
Rep: Reputation: 51
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!
 
Old 08-30-2014, 06:38 AM   #7
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with find command and rar/unrar command line krakatoa1 *BSD 6 09-11-2012 04:21 PM
[SOLVED] Find a file in directories without using find command sikanders Linux - Newbie 14 08-06-2010 09:47 PM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 06:55 PM
Single find command to find multiple files? thok Linux - Newbie 7 01-31-2009 05:45 PM
Help needed for find command ZAMO Linux - General 7 09-23-2008 05:15 AM


All times are GMT -5. The time now is 01:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration