LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-04-2019, 05:31 PM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
How make rsync deal with spaces in a directory name?


Thanks to help from linuxquestions, I can back up this laptop to another laptop using rsync. Works great and extremely quickly!

You probably know that old TV series 24. America is just full of bad guys, and they all want to get Jack Bauer! It's rubbish I know, but it relaxes me in the evening.

Yesterday, I wanted to copy a directory 24 Season6 from a usb to my old laptop. Thought I would use rsync, as I am very impressed with that program!

But I kept getting errors. I think it is because of the space in the directory name.

The usb is at /media/pedro/X3

I tried:

Quote:
rsync /media/pedro/X3/24 Season6 /home/pedro/24
but I kept getting a 'can't stat' error 'no such file or directory'

Is it the space causing the error?
 
Old 12-04-2019, 05:42 PM   #2
uteck
Senior Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: Ubuntu based stuff for the most part
Posts: 1,174

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
you need to mark the space so bash knows it is there. In Linux, most Unix, that is done with the backslash \
So "24 Season6" on the command line is "24\ Season6"
Code:
rsync /media/pedro/X3/24\ Season6 /home/pedro/24

Last edited by uteck; 12-04-2019 at 05:43 PM.
 
1 members found this post helpful.
Old 12-04-2019, 06:09 PM   #3
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554Reputation: 2554
In addition to backslashes, you can also wrap the whole name in quotes. (Useful if a path would have lots of spaces.)

Also, for local paths you can use tab-completion - try typing...
Code:
/me<tab>/p<tab>/X3/24<tab>6
...and (depending on which other files/dirs exist), you may get the whole path with half as many key presses.
 
1 members found this post helpful.
Old 12-05-2019, 12:00 AM   #4
FlinchX
Member
 
Registered: Nov 2017
Distribution: Slackware Linux
Posts: 666

Rep: Reputation: Disabled
Quote:
Originally Posted by boughtonp View Post
In addition to backslashes, you can also wrap the whole name in quotes.
Yes. And they better be single quotes. Because $foo inside double quotes will get interpreted as variable with name foo by shell.
 
  


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
LXer: Tabs or spaces? Spaces, obviously, but how many? LXer Syndicated Linux News 0 09-13-2018 09:50 AM
How to deal with spaces in command line arguments satya123 Linux - Newbie 14 05-25-2012 11:59 AM
bash: 'find ./ -type d' how to deal with directories with spaces? xaos5 Programming 4 09-06-2009 06:30 PM
Spaces and escaped spaces pslacerda Linux - Newbie 13 12-20-2008 09:03 AM
Creating an alias (name=value pair) where the name has spaces. Cubert Linux - Newbie 2 01-12-2005 06:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:01 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
Open Source Consulting | Domain Registration