Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for a way to scan a directory recursively and print out all instances of any file that ends ".qfx". Thus, for a given directory:

somedir/
    fizz.qfx
    buzz.qfx
    blah/
        foo.qfx
        widget.js
        meh/
            bar.qfx
            derp.gif

The output would be:

somedir/fizz.qfx
somedir/buzz.qfx
somedir/blah/foo.qfx
somedir/blah/meh/bar.qfx

I'm on Ubuntu so no preference in shell, python, perl, etc. Best attempt so far is:

find -name ".qfx" somedir

But getting the following error:

find: paths must precede expression: .
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec][path...] [expression]

Any ideas? Thanks in advance!

share|improve this question

migrated from stackoverflow.com Jun 18 '13 at 23:59

This question came from our site for professional and enthusiast programmers.

    
Sorry, but asking this question is just ultimately lazy (despite it being verbose and nicely (time-consuming?) formatted. The error tells you exactly what you're doing wrong. –  tink Jun 19 '13 at 0:25

2 Answers 2

up vote 2 down vote accepted

it tells you to put the directory before the -name expression. Also, you need a * to match for all files:

find somedir -name "*.qfx" 
share|improve this answer

In the case you're using zsh as shell, you can also use ls **/*.qfx, which is pretty useful.

share|improve this answer
1  
also works in bash if the globstar option is enabled: shopt -s globstar –  mata Jun 18 '13 at 23:29
    
@mata true, however that is bash version 4 or later. –  jaypal Jun 19 '13 at 4:00

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.