LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 06:31 PM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 18.04
Posts: 1,760

Rep: Reputation: 67
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, 06:42 PM   #2
uteck
Member
 
Registered: Oct 2003
Location: Elgin,IL,USA
Distribution: GalliumOS on Chrombook
Posts: 298

Rep: Reputation: 60
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 06:43 PM.
 
1 members found this post helpful.
Old 12-04-2019, 07:09 PM   #3
boughtonp
Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 47

Rep: Reputation: 13
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, 01:00 AM   #4
FlinchX
Member
 
Registered: Nov 2017
Distribution: Slackware Linux
Posts: 376

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

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