Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there an alternative find program with a more conventional CLI interface? find works and expects parameters in a painfully different way from most other utils.

Clarification: I'm looking for a program that has mostly the same functionality as find with a commandline interface that works and feels like POSIX (or at least GNU) commandline recommendations.

share|improve this question
1  
I'm not entirely sure what you mean by 'more conventional', here... Perhaps you can clarify your question? –  Shadur May 20 '11 at 11:05
3  
GNU find does not respect POSIX (or even GNU) guidelines for command line. For example, ordering of parameters, multi-character options with a single dash etc. are different than in conforming programs. –  Tamás Szelei May 20 '11 at 11:11
2  
find is both consistent (see my answer) and intuitive. It's not like primaries are named weird. -exec means execute, -print means print it, -name means match a name. In practice, the former 3 and -type cover 95% of the usage cases. For all other cases, there's man find. –  Mel May 20 '11 at 16:27
3  
@tamas I edited an hour ago and told you there's no alternative except locate. And maybe ls -R come to think of it. Other alternatives are GUI programs that emulate find. Otherwise you have to specify what you want your find alternative to do. Walk dir trees? Filter file names? Tell you which files is newer then? –  Mel May 20 '11 at 17:24
2  
What do you want it to do? What should the syntax look like? –  Mikel May 21 '11 at 0:54

5 Answers 5

It depends on the precise functionality of find that you are relying on. If it is (principally) the finding functionality, some shells support recursive globs. E.g., with zsh:

% find . -name \*c
./a/b/foo.c
./a/bar.c
./baz.c
inoshiro% ls *.c
baz.c
% ls **/*.c 
a/bar.c  a/b/foo.c  baz.c

Zsh has a lot more find-like possibilities through glob qualifiers (look near the end of man zshexpn). For example:

ls -l **/*(.)  ≈  find -type f -ls
ls *(m-2u:$USER:)  ≈  find -mtime -2 -user $USER

Bash 4 also has **/ (you need to enable it with shopt -s globstar), but nothing like glob qualifiers.

share|improve this answer

This is a common misconception.

Find follows the options syntax. You're just confusing expression primaries with options:

 find [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
 [cmd][-->        options          <--] [--> arg0..argN  <--]

The alternative is locate. But find implements it's own expression syntax because it provides a richer set of filter and action options. There's no alternative that can do the same, simply because it would be redundant.

share|improve this answer
1  
Even if it's my fault, this does not answer my question. –  Tamás Szelei May 20 '11 at 14:29
    
What is the difference between expression (only one allowed?), cmd (dito?), options and args? –  user unknown May 20 '11 at 15:35
    
@user unknown -- the find command implements it's own expression syntax. The expression, when given, is the last argument on the command line. When absent, expression resolves to -print. –  Mel May 20 '11 at 16:03
    
Ah - now I see, [cmd] isn't following [expression], but it's a description of the line before. –  user unknown May 21 '11 at 3:04

I would take a look at locate. It will look through its database of files and quickly print out path names that match what you give.

kevin@box:~$ locate odg
/home/kevin/Documents/final.odg
/usr/share/doc/packages/sysconfig/netconfig.odg
/usr/share/gimp/2.0/help/en/gimp-tool-dodge-burn.html
....
kevin@box:~$ locate .odg
/home/kevin/Documents/final.odg
/usr/share/doc/packages/sysconfig/netconfig.odg
kevin@box:~$ 

As you can see, it is a sub-text match: if you give it odg, then it will match dodge. But if you give it .odg, then it won't.

There is one downside, though: it needs a database. This database needs to be updated when things change. My Fedora 13 install has this put into a daily crontab, though.

share|improve this answer
    
I love locate –  Andrew Lambert May 21 '11 at 10:00
    
Moreover, locate also accepts patterns (I learned this just recently). –  Adam Byrtek May 21 '11 at 17:55

What are you trying to find? If you're typically searching for source code files, take a look at ack. It's basically a source code search tool, but ack's -f switch will find files that match a given filetype.

So if you want to find all the Perl files in a directory, for example, just:

ack -f --perl

If you don't like the filetypes that ack recognizes, you can add your own in your ~/.ackrc.

ack is not a general-purpose file finder like find, but if you're working with source code, it can be very handy.

share|improve this answer

One of the great things every programmer should learn is: If you can't find a tool, build your own!

#!/usr/bin/bash
find -name $<

I might write a better one, with -t to filter types, etc.

Edit: The above is a Bash script. It takes the command line argument and passes it to find as the -name option's value. Just a simple example. Since I put up this answer, I found this python script:

https://github.com/sjl/friendly-find/

The interface looks nice, but I haven't tested its performance. Might be worth checking out.

share|improve this answer
1  
True for building own tool statement. But at least explain how your little script is supposed to work. –  jippie Dec 16 '12 at 9:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.