Training, Open Source computer languages

PerlPHPPythonMySQLhttpd / TomcatTclRubyJavaC and C++LinuxCSS

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Copy multiple files - confusing error message from cp
Thought you might like me to share this one ...

Copying a whole series of files into a directory (Linux, Unix, OS X) using cp, you give a whole series of source files followed by the name of the target directory. Add the -r option is you want to specify subdirectories to be copied recursively in your input.

So this should work, eh?

grahamellis$ cp -r whc.css images grgen.php ~/back_20061229/htaccess
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target
cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory
grahamellis$


What an odd result. Is the -r option wrong? No - that's not the problem. In my opinion, there's a bug in cp in that the usage line is incomplete, but that's not the real problem. The real problem was that I specified an existing file name as the target for my copy, and cp won't copy a whole series of files into one.

If I correct my command (by specifying a target directory name), it works perfectly:
grahamellis$ cp -r whc.css images grgen.php ~/back_20061229
grahamellis$


Footnote - if you want to preserve file ownerships as you copy them, use tar instead of cp. You need administrator access (i.e. be logged in as root) to do this.
(written 2006-12-30 09:59:53)

 
Associated topics are indexed under
A101 - Web Application Deployment - Linux -An Introduction For Users
A162 - Web Application Deployment - Backups and File System Management

Back to
Moving files between Windows / DOS and Linux / Unix
Previous and next
or
Horse's mouth home
Forward to
Christmas Season Piccies

Some other Articles
css - handling white space and pre
Modernising from tables to cascading style sheets
Search engine placement - long term strategy and success
Christmas Season Piccies
Copy multiple files - confusing error message from cp
Moving files between Windows / DOS and Linux / Unix
Well House Manor and Beechfield House, Hotels, Melksham
Dates, times, clickable diarys in PHP
Passing GET parameters through Apache mod_rewrite
Date conversion - PHP
1638 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho