copy particular extension files recursively and store it in same folder structure ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • finddata15
    New Member
    • Feb 2017
    • 1

    copy particular extension files recursively and store it in same folder structure ?

    How do I copy particular extension files recursively and store it in same folder structure?

    Code:
     
        use strict;
        use warnings;
    
        my $pwd         = "/home/ra/DEMO";
        my $destination = "/home/ra/output";
    
        opendir(DIR, "$pwd") or die "Error";
        my @files = readdir(DIR);
        closedir(DIR);
    
        foreach my $file ( @files ) {
            next if ($file !~ /\.config$/i);  # filtered only file with extension .config
            system(`cp "$pwd $file" "$destination"`); 
        }
    Last edited by Frinavale; Feb 27 '17, 02:37 PM. Reason: Added the question to the body of the thread
Working...