LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-29-2009, 10:17 AM   #1
ThatDevilTux
LQ Newbie
 
Registered: Jul 2009
Location: Longview, TX
Distribution: Ubuntu, SUSE, openSUSE
Posts: 2

Rep: Reputation: 0
Help with the find command


Morning Everyone,

I'm hoping to get some quick help, I've tried to look online and searched the site but didn't find exactly what I was looking for. What I need is a command to find all executables that contain a certain letter in their filename.

For instance, after creating three files: a.file A.file and file.a and making them executable, I need to do a find command to find those three executable files.

More files could be found, but I need to be able to pull those three in one command. Does that make sense? Any help would be greatly appreciated. I haven't mastered the command-line at all.

TDT
 
Old 07-29-2009, 11:33 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,388
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
Code:
find . -iname "*a*" -executable -type f
The find command is quite powerful; if you type 'man find' this will give you a description of the many parameters.

The example above looks in the current directory '.' (and all subdirectories) for a file with an 'a' in it (-name "*a*"), which has the execute permission set (-executable), and which is of type file (-type f). The reason for restricting the type is because directories also have execute permission, for reasons I won't go into here.

At a later point if you need instead to search by files by content rather than external attributes, you would make use of a command line program called 'grep'.

Last edited by neonsignal; 07-29-2009 at 11:35 AM.
 
Old 07-29-2009, 04:54 PM   #3
ThatDevilTux
LQ Newbie
 
Registered: Jul 2009
Location: Longview, TX
Distribution: Ubuntu, SUSE, openSUSE
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks for the reply. That is what I needed. I could get the -name part, but the executable switch was tripping me up. I really would love to learn a lot more about Linux/UNIX and eventually feel comfortable enough to replace Windows with it on a laptop I have, and maybe eventually on the servers at work. But, that will be a ways down the road for me right now. But, it's a destination I would love to get to.
 
Old 07-29-2009, 05:05 PM   #4
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
The GNU Info document Finding Files is well worth reading. IMHO it explains find a little better than the man page. If the Info documentation is not already installed, look for it in your package manager.
 
  


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
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 06:30 PM
Single find command to find multiple files? thok Linux - Newbie 7 01-31-2009 05:45 PM
Using a single "Find" Command to find files bases on multiple criteria roboxooo Linux - Newbie 6 01-15-2009 05:13 AM
can't find my find command! how to replace? dave247 Debian 4 11-19-2008 11:51 AM
not find mt command imsajjadali Red Hat 2 02-07-2004 07:27 AM


All times are GMT -5. The time now is 04:28 AM.

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