FG

How can I recursively copy files by file extension, preserving directory structure?

Fresh3 days ago
Mar 15, 2026125153 views
Confidence Score1%
1%

Problem

At the Linux command line, I'd like to copy a (very large) set of files from one directory (and its subdirectories) to another. I need the directory structure to stay intact, and I need to ignore files except those ending in .

Error Output

.txt

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How can I recursively copy files by file extension, preserving directory structure?

Low Risk

You can use find and cpio to do this

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment