LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-02-2008, 06:11 AM   #16
rash31
LQ Newbie
 
Registered: Sep 2008
Location: Nigdi, Pradhikaran Pune
Distribution: debian, rpm
Posts: 7
Blog Entries: 2

Rep: Reputation: 0

If you want to use loop anyhow to execute your output as you desire. I suggest you can use it as

for file in "$(cd dir1 | find . -type f)"
do
cp $file dir3
echo $file
done

This will only copy your files from dir1 to dir3 and will ignore the subdirectories from getting copied in dir3.

But, if you want to copy the subdirectories as well then use the loop as

for file in "$(cd dir1 | ls)"
do
cp $file dir3
echo $file
done
And this will work f9.
 
  


Reply



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
Bash shell how to copy all except file1,directory1,etc bgeddy Programming 5 08-31-2008 07:58 PM
copy directories and files recursively using C shell or bash shell bostonuser Programming 7 06-06-2008 01:24 AM
how to rename a file and copy a file in a shell zach014 Linux - Newbie 6 11-23-2006 09:23 AM
Bash : Copy a file every one minute macabre_sunsets Programming 15 09-16-2006 12:26 AM
make a file in dir1 appear to be in writeprotected dir2 magicpio Linux - Newbie 2 09-25-2005 01:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:36 PM.

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
Open Source Consulting | Domain Registration