Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 singh Jun 19 '13 at 4:00
find /u02/fullbackup -name *.bck -print
find: paths must precede expression: arc_381465332_OSOS_20160219_2879_1.bck
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

solution:

find /u02/fullbackup -name '*.bck' -print

/u02/fullbackup/dbf_381465332_OSOS_20160219_2872_1.bck
/u02/fullbackup/arc_381465332_OSOS_20160219_2882_1.bck
/u02/fullbackup/arc_381465332_OSOS_20160219_2892_1.bck
/u02/fullbackup/arc_381465332_OSOS_20160219_2894_1.bck
/u02/fullbackup/arc_381465332_OSOS_20160219_2891_1.bck
/u02/fullbackup/arc_381465332_OSOS_20160219_2885_1.bck
/u02/fullbackup/dbf_381465332_OSOS_20160219_2871_1.bck
/u02/fullbackup/arc_381465332_OSOS_20160219_2888_1.bck
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .