LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-25-2009, 04:12 AM   #1
jenser2
LQ Newbie
 
Registered: Mar 2008
Posts: 12

Rep: Reputation: 0
Recursive remote copy using wildcards


Hi guys,

I have a bunch of directories on a remote machine which look like they contain identical files and subdirectories but are the output of different model runs, so their content is different. The total output is quite large, so I want to copy certain files from certain subdirectories down to a local machine so I can compare the output from different runs. The directory structure has to be replicated, as the filenames are identical from each run.

Is there a one line command to do this or do I need to write a script? On the remote machine I have

/modeldir/expt1/subdir/file1 file2 file3
/modeldir/expt2/subdir/file1 file2 file3
/modeldir/expt3/subdir/file1 file2 file3

and would like to be able to do something like

scp -r user@remote:/modeldir/*/subdir/file[1-3] .

so that the directory structure is copied recursively. When I do this command, scp comes back with a 'no match' error message. When I do the following:

scp -r user@remote:/modeldir/expt1/subdir/file1 .

file1 gets copied to . without the subdirectories being recreated.

Any help appreciated!

Jenser
 
Old 05-25-2009, 04:39 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can try rsync in place of scp, so that the directory structure is created/preserved on the local machine:
Code:
rsync -e ssh -avz  user@remote:/modeldir .
If you want to copy just some files, use the proper include and exclude options. The following includes all the directories, includes all the files whose name: start with "file" and exclude the rest
Code:
rsync -e ssh -avz --include='*/' --include='file*' --exclude='*' user@remote:/modeldir .
HTH.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
K3b Recursive Copy tronayne Slackware 6 08-21-2007 07:43 AM
Recursive Copy / Create Luvz2Fly Programming 5 11-18-2006 04:52 PM
Recursive Copy of certain files Whiskerz Linux - Newbie 5 12-18-2005 07:06 PM
copy problem using wildcards plisken Linux - General 11 11-16-2005 08:34 AM
Recursive Copy fizgig10 Linux - Newbie 1 07-16-2005 11:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration