By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,670 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,670 IT Pros & Developers. It's quick & easy.

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

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

Expand|Select|Wrap|Line Numbers
  1.  
  2.     use strict;
  3.     use warnings;
  4.  
  5.     my $pwd         = "/home/ra/DEMO";
  6.     my $destination = "/home/ra/output";
  7.  
  8.     opendir(DIR, "$pwd") or die "Error";
  9.     my @files = readdir(DIR);
  10.     closedir(DIR);
  11.  
  12.     foreach my $file ( @files ) {
  13.         next if ($file !~ /\.config$/i);  # filtered only file with extension .config
  14.         system(`cp "$pwd $file" "$destination"`); 
  15.     }
  16.  
Feb 27 '17 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.