LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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-01-2006, 09:55 AM   #1
Freestone
Member
 
Registered: Jan 2003
Location: Brighton, Michigan
Distribution: FC5
Posts: 114

Rep: Reputation: 15
cp command question


Hello LQ,

I'm not a total noob but I feel like on with this question.

I want to copy the contents of one folder into another from a command line. From a gui, what I'm trying to do is simple but I want to do it from terminal. Here is the issue:

Say I have a folder called-------------/data
A folder in /data is /files -------------/data/files
I then make a new directory---------mkdir /data2

I want to copy the contents of /data/files into /data2, but from my limited knowledge I've only been capable of producing the following with the command cp /data/files /data2:

Result-------------------------------------/data2/files/blah blah blah
My desired result----------------------/data2/blah blah blah

It creates the directory 'files' in /data2.
I don't want to create a directory 'files' in /data2, I just want the contents from /data/files to be placed into /data2, without creating a directory 'files' in /data2. Follow me?

Is there a way to copy the contents of a directory into another without creating a new directory in the destination directory?

Thanks for any insight,
Freestone
 
Old 05-01-2006, 10:04 AM   #2
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
cp /data/files/* /data2
 
Old 05-01-2006, 10:12 AM   #3
Freestone
Member
 
Registered: Jan 2003
Location: Brighton, Michigan
Distribution: FC5
Posts: 114

Original Poster
Rep: Reputation: 15
I got it. I didn't realize the '*' was so critical.

Thanks. Always learning something new.

Freestone
 
Old 05-01-2006, 10:15 AM   #4
uselpa
Senior Member
 
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507

Rep: Reputation: 46
Well, the first meant "the directory" and the second means "all files in the directory". Sometimes this does make a difference.
Look a bit deeper into `man cp`. Flags like -R and -a might be very useful in your situation.
 
Old 05-01-2006, 10:39 AM   #5
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 30
Why not just move the directory or symlink it.

Last edited by ioerror; 05-01-2006 at 10:40 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Command question satimis Fedora 3 04-04-2005 01:24 AM
ls command question eastj1974 Linux - Newbie 4 11-18-2003 06:44 PM
cp command question satimis Linux - Newbie 1 09-13-2003 09:31 PM
SU command question downinthemine Linux - Newbie 25 07-31-2003 09:21 PM
Command Question gauge73 Linux - Newbie 2 02-13-2003 09:18 PM


All times are GMT -5. The time now is 04:16 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration