Copy a directory from one machine to another from command line

Today I have to run some tests on various machines and have to post the results to a common directory in another machine.Since most of the machines are accessed through command line,I dont have any GUI to copy and paste.

Again making a zip file to the directory and then ftp it to target macine and then unzipping it , looked odd.So I googled out to find a simple way and found the below command to copy an entire directory in a single go:

tar -cf - <dir-to-be-copied> | ssh <user-name>@<target-machine> "cd target_dir; tar -xf -"

Now it asks for the user password and once you key in the password and hit enter, its done!!!

The above command copies the whole directory to the target machine. But this needs the machine has ssh setup on it.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

This is my personal blog.All the information here reflects my own thoughts and feelings and should not be taken as official information from Oracle.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today