[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Copying all files from one directory to another?

Posted on 2004-08-05
3
Medium Priority
?
292 Views
Last Modified: 2012-05-05
Suppose I am in the directory /gopi
And there are directories called as publicsource and publicdest in this /gopi directory.publicsource has some files in it whereas publicdest is empty directory.
 So how to copy all files from publicsource to publicdest from /gopi directory?
When I did,
cp -fR /gopi/publicsource /gopi/publicdest
the directory publicsource is itself getting copied to publicdest directory but i want only the files to be copied. So please help me.Thanks.
0
Comment
Question by:gopikrish
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
brettmjohnson earned 200 total points
ID: 11731860
Try:
 cp -fR /gopi/publicsource/* /gopi/publicdest

Or
 (cd  /gopi/publicsource; tar -cf -) | (cd  /gopi/publicdest; tar -xf -)



0
 

Author Comment

by:gopikrish
ID: 11732984
Ok and what does the following command do?
"cp -f /home/files/myfirstscript ."
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 11733075
> Ok and what does the following command do?
> "cp -f /home/files/myfirstscript ."

It makes a copy of  /home/files/myfirstscript  in the current directory (.).
The copy will have the same name as the original.  The -f switch  forces
any existing file in the current directory by that name to be overwritten.

0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question