How to copy a file from one location to another location?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to copy a file from one location to another location?
# 1  
Old 01-12-2012
How to copy a file from one location to another location?

I have file file1.txt in location 'loc1'. Now i want a copy of this file in location 'loc2' with a new file called test.txt.

Please help me how to do this in shell script.
# 2  
Old 01-12-2012
If loc2 is same server then use cp, else if its different server then use scp command

Code:
cp ${loc1}/file1.txt ${loc2}/test.txt 
 
(or)
 
scp hostname:${loc1}/file1.txt hostname:${loc2}/test.txt

This User Gave Thanks to Rksiva For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and Copy file of specific location

Dear All, I need to transfer all files present in one location to another but those files should be of specific extension like. Find and copy all files of extension .xls, .pdf, .txt from location usr/tmp to location /per/Treat (6 Replies)
Discussion started by: yadavricky
6 Replies

2. Shell Programming and Scripting

Copy file from UNIX to shared location

Hi All, I want to transfer file from UNIX to shared locataion . Shared location doesn't resides on my system. Can somebody tell me is there any way i can transfer file from UNIX to shared location without using any tool WINSCP. Thanks, Amit (1 Reply)
Discussion started by: Amit786
1 Replies

3. Shell Programming and Scripting

How to find a existing file location and directory location in Solaris box?

Hi This is my third past and very impressed with previous post replies Hoping the same for below query How to find a existing file location and directory location in solaris box (1 Reply)
Discussion started by: buzzme
1 Replies

4. UNIX for Dummies Questions & Answers

how to copy files and record original file location?

:EDIT: I think my post name should have been labeled: how to copy files and record original file location. not "retain". Hello, this is my first post! I searched the forums a lot before posting, but was unable to answer my question. Here's my problem: There are several hundred text files... (4 Replies)
Discussion started by: willie8605
4 Replies

5. Shell Programming and Scripting

File created in a different location instead of desired location on using crontab

Hi, I am logging to a linux server through a user "user1" in /home directory. There is a script in a directory in 'root' for which all permissions are available including the directory. This script when executed creates a file in the directory. When the script is added to crontab, on... (1 Reply)
Discussion started by: archana.n
1 Replies

6. Shell Programming and Scripting

Shell Script for Copy files from one location to another location

Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval. (2 Replies)
Discussion started by: allways4u21
2 Replies

7. Shell Programming and Scripting

Put one string from one location to another location in a file

Hi Everyone, I have 1.txt here a b c' funny"yes"; d e The finally output is: here a b c d e' funny"yes"; (1 Reply)
Discussion started by: jimmy_y
1 Replies

8. Shell Programming and Scripting

tail copy of a file to remote location

Hello, I have a solaris box and a windows server. The windows server runs cygwin for ssh service. I have an audit log in solaris box. When ever new records are added to the log file, this delta has to be trasported to a remote file in windows. I can do a ssh once in a while, but want the... (7 Replies)
Discussion started by: unori
7 Replies

9. UNIX for Advanced & Expert Users

copy files from one location to similar location

I need help in forming a script to copy files from one location which has a sub directory structure to another location with similar sub directory structure, say location 1, /home/rick/tmp_files/1-12/00-25/ here 1-12 are the number of sub directories under tmp_files and 00-25 are sub... (1 Reply)
Discussion started by: pharos467
1 Replies

10. UNIX for Dummies Questions & Answers

excutable script to copy a file to a different location.

Hi, I'm try to create an executable file to copy a file to a different location. Help plz. Thanx. (4 Replies)
Discussion started by: nazehcalil
4 Replies
Login or Register to Ask a Question