Reputation: 13
I want to copy recursively all files ending .pl
If I ls -R | grep -F .pl
I can see all of them, however if I type any of the following commands I just get the *.pl files in the current directory
cp -R *.pl
find . | ls *.pl
ls -r | ls *.pl
ls -R | grep -F .pl
(with this one I get only a few)
also if I want to scp copy with scp -r user@address:/directory/*.pl .
I only get the files in the current directory
with find . -name \*.pl
I don't get all of them, only a few files
How can I copy all files *.pl in all the subdirectories?
Upvotes: 1
Views: 5528
Reputation: 741
This command works just fine with only a single SSH authentication required.
scp $(find . -name *.pl) $server_address:/destination/path/
Upvotes: 1
Reputation: 4877
find path/to/dir -name "*.pl" -exec "cp" "{}" your/dest/dir ";"
EDIT (2015/01/23): Someone suggested (via an edit to this post) that on his shell it didn't work with the quotes and he had to remove them. I don't know which shell is that (:P) but it said it worked the following way:
find path/to/dir -name *.pl -exec cp {} your/dest/dir \;
Essentially, the quotes were to avoid the expansion of the asterisk to a list of files (which would happen automatically in bash if you had file with that extension in your current working directory), to avoid misinterpretation of the curly braces in some situations, and to avoid interpretation of the semicolon (;
) which signals the end of the statement for bash (while we want it as an argument for find).
Upvotes: 3