Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 have close to hundreds of .fastq files in different subfolders under a shared drive along with many big files such as .bam files. I want to copy only the .fastq files to another location in a same folder to perform an analysis. How can I do it on a Mac? I tried:

find -E . -iregex '.*/*\.fastq'

which showed all the files along with the relative path, but I don't need the path. And I cannot figure out a pipeline to copy them to another location.

share|improve this question

migrated from Apr 2 '13 at 18:30

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

up vote 3 down vote accepted

You don't need to use regexes if you're just looking for files with a particular extension.

find . -name '*.fastq' -exec mv {} /new/dir/ \;
share|improve this answer
Thank you very much. It works perfectly. – user2237343 Apr 2 '13 at 18:42

Your Answer


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.