LinuxQuestions.org
Register a domain and help support LQ
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 12-22-2009, 02:12 AM   #1
spartanz
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
how to copy files from directory


i have four directories and i want to copy only the files in the directory to a single directory, how can i do it with the cp command.

the directories names are dir1, dir2, dir3 and dir4 and i want only the files from these directories to a single directory called mainDir.

Thanks in advance
 
Old 12-22-2009, 02:21 AM   #2
Kenichi Kato
Member
 
Registered: Jun 2007
Location: Asia
Distribution: Ubuntu, Fedora, CentOS & TCL
Posts: 62
Blog Entries: 1

Rep: Reputation: 16
OK, you could do this:

cp -p dir1/* mainDir/

then replace dir1 with dir2 & so on.
 
Old 12-22-2009, 02:22 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
What did you learn in class? Which resources are you using to learn Linux commands? What have you tried so far? LQ does not exist to do your homework for you but will help you when you try yourself and get stuck.
 
Old 12-22-2009, 02:29 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

Just as catkin stated, we're not here to do your homework for you. This is basic stuff that you should know or can easily learn. Just check out the man page for cp and read up on Linux.

Code:
man cp
Here are some links to learn Linux commands.

http://www.pixelbeat.org/cmdline.html
http://www.oreillynet.com/linux/cmd/
http://ss64.com/bash/

Kind regards,

Eric
 
  


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
find files with pattern, then copy those files to another directory ncsuapex Programming 4 08-13-2010 04:38 PM
How to Copy files from local directory to a particular directory using alias dynamics Linux - Newbie 7 09-11-2009 05:19 PM
How to copy files after search in array from this directory to another directory! phanvinhgiap Programming 4 01-04-2009 07:48 PM
copy 3 files to a directory and all subdirectories? snip128 Linux - Newbie 9 08-12-2005 10:18 PM
copy files from directory to directory without subfile ALInux Linux - General 2 06-03-2005 12:51 PM


All times are GMT -5. The time now is 02:28 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