![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Copy files from a directory by ftp | hippa77 | UNIX for Dummies Questions & Answers | 3 | 10-06-2007 11:26 AM |
| find files and copy into a directory | balireddy_77 | Shell Programming and Scripting | 4 | 04-27-2007 12:38 AM |
| Copy files from CDROM to DOS Directory | greystoke | UNIX for Dummies Questions & Answers | 3 | 01-24-2007 10:12 AM |
| Copy files from one directory to another | HAA | Shell Programming and Scripting | 1 | 07-05-2006 11:47 PM |
| Copy files from one directory to another | hd2006 | Shell Programming and Scripting | 0 | 06-07-2006 11:29 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
how do i copy files from one directory to another directory using a while loop? (like jus say i had a.doc and b.doc in one directory and i want to copy it into another)
i used a if statement but doesn't work |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
You don't need a while loop. Something like
cp -R dir_a/ dir_b should work. |
|
#3
|
|||
|
|||
|
cbkihong's example will work to copy entire directorys over. that seems like what you were asking. the -r flag for the cp command tells cp to copy directories recursivley.
coping individual files works the same way, just without the -r flag. eg: cp file1 somewhere/file1 |
|
#4
|
|||
|
|||
|
yeh i did that.....but it keeps having a error that says "too many arguments"
for my if statement i got if [ -f $HOME/$directory/*.src ] is there something wrong with that if multiple files are to be copied? |
|
#5
|
|||
|
|||
|
The -f test doesn't accept multiple arguments. *.src is expanded by the shell to all matching filenames, so there are multiple arguments. As being said, from your description you don't even need an "if" to do it. It's as simple as
cp *.src dir_b/ |
|
#6
|
||||
|
||||
|
...............
searching for that?:
for x in $HOME/$directory/*.src do cp $x $NEWDIR done greetings Preßy |
||||
| Google The UNIX and Linux Forums |