Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy directory contents containing space 1

Status
Not open for further replies.

datadan

IS-IT--Management
Jul 22, 2002
283
US


I want to:

cp -R /usr/folder/first last/* /usr/folder/newuser/

However copy is choking ont he space between first and last of the source directory.

Clever ideas on how I can copy contents of cp -R /usr/folder/first last/*?

Thanks,
 
Did you try putting the source and dest in quotes?

Like:

Code:
cp -R "/usr/folder/first last/*" /usr/folder/newuser/

Worth a try. Otherwise, escaping like jrjuiliano suggested will work.

If you are unsure of the escaping, try using tab for autocomplete. Most shells do that. To use that, type the first few letters of the folder with the space and press the tab key:

cp -R /usr/folder/fi<TAB> ...

It should autocomplete for you with escaping if the shell supports it.
 
If this is the only folder called first<whatever> in the directory, then

cp -R /usr/folder/first*/* /usr/folder/newuser

should work.
 
I would take jrjuiliano's advice and escape the spaces -- escape mean putting a backslash in front of the space. You can also escape other characters that have the same sort of problems.

Code:
cp -R /usr/folder/first\ last/* /usr/folder/newuser

If you're using one of the more common shells, you can save time by useing the TAB key like danomac suggests. Or pressing it twice if there's more than one folder that starts with 'first'.

Steve Kiehl
Web Page Designer - Nanovox Productions
Fantasy Artist - Zeadi
 
GREAT!

Thank for your help. I used the cp -R "/.../" method.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top