How do I scp a filename with spaces?

Clash Royale CLAN TAG#URR8PPP up vote
6
down vote
favorite
I'm having a little difficulty using scp to transfer files from a remote computer. The issue apparently has to do with the name of the directory the files are contained in. They're on a CD drive called photos 4 (with a space between photos and 4). When I attempted the transfer, I used the following command:
scp [remote username]@192.168.1.X:/media/[remote username]/photos 4/file.jpg /home/[username]/Pictures
However, I get an error message in return saying No directory: /media/[remote username]/photos. I thought the backslash would escape the space so that the directory would be read as photos 4.
Can someone fill me in on what I'm doing wrong here?
(As an aside, I made a copy of file.jpg to the remote computer's desktop and then ran the command:
scp [remote username]@192.168.1.X:/home/[remote username]/Desktop/file.jpg /home/[username]/Pictures
and it worked, so that escape sequence seems to be the culprit. I just can't figure out what's wrong with it.)
command-line ssh transfer scp
add a comment |Â
up vote
6
down vote
favorite
I'm having a little difficulty using scp to transfer files from a remote computer. The issue apparently has to do with the name of the directory the files are contained in. They're on a CD drive called photos 4 (with a space between photos and 4). When I attempted the transfer, I used the following command:
scp [remote username]@192.168.1.X:/media/[remote username]/photos 4/file.jpg /home/[username]/Pictures
However, I get an error message in return saying No directory: /media/[remote username]/photos. I thought the backslash would escape the space so that the directory would be read as photos 4.
Can someone fill me in on what I'm doing wrong here?
(As an aside, I made a copy of file.jpg to the remote computer's desktop and then ran the command:
scp [remote username]@192.168.1.X:/home/[remote username]/Desktop/file.jpg /home/[username]/Pictures
and it worked, so that escape sequence seems to be the culprit. I just can't figure out what's wrong with it.)
command-line ssh transfer scp
Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
â pauljohn32
Jul 14 '16 at 4:43
That's fine, unless you're scp'ing files that you didn't name.
â Alcuin Arundel
Jul 14 '16 at 4:46
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I'm having a little difficulty using scp to transfer files from a remote computer. The issue apparently has to do with the name of the directory the files are contained in. They're on a CD drive called photos 4 (with a space between photos and 4). When I attempted the transfer, I used the following command:
scp [remote username]@192.168.1.X:/media/[remote username]/photos 4/file.jpg /home/[username]/Pictures
However, I get an error message in return saying No directory: /media/[remote username]/photos. I thought the backslash would escape the space so that the directory would be read as photos 4.
Can someone fill me in on what I'm doing wrong here?
(As an aside, I made a copy of file.jpg to the remote computer's desktop and then ran the command:
scp [remote username]@192.168.1.X:/home/[remote username]/Desktop/file.jpg /home/[username]/Pictures
and it worked, so that escape sequence seems to be the culprit. I just can't figure out what's wrong with it.)
command-line ssh transfer scp
I'm having a little difficulty using scp to transfer files from a remote computer. The issue apparently has to do with the name of the directory the files are contained in. They're on a CD drive called photos 4 (with a space between photos and 4). When I attempted the transfer, I used the following command:
scp [remote username]@192.168.1.X:/media/[remote username]/photos 4/file.jpg /home/[username]/Pictures
However, I get an error message in return saying No directory: /media/[remote username]/photos. I thought the backslash would escape the space so that the directory would be read as photos 4.
Can someone fill me in on what I'm doing wrong here?
(As an aside, I made a copy of file.jpg to the remote computer's desktop and then ran the command:
scp [remote username]@192.168.1.X:/home/[remote username]/Desktop/file.jpg /home/[username]/Pictures
and it worked, so that escape sequence seems to be the culprit. I just can't figure out what's wrong with it.)
command-line ssh transfer scp
edited Jun 12 at 9:09
muru
128k19269459
128k19269459
asked Apr 15 '16 at 20:58
Alcuin Arundel
2,00711022
2,00711022
Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
â pauljohn32
Jul 14 '16 at 4:43
That's fine, unless you're scp'ing files that you didn't name.
â Alcuin Arundel
Jul 14 '16 at 4:46
add a comment |Â
Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
â pauljohn32
Jul 14 '16 at 4:43
That's fine, unless you're scp'ing files that you didn't name.
â Alcuin Arundel
Jul 14 '16 at 4:46
Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
â pauljohn32
Jul 14 '16 at 4:43
Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
â pauljohn32
Jul 14 '16 at 4:43
That's fine, unless you're scp'ing files that you didn't name.
â Alcuin Arundel
Jul 14 '16 at 4:46
That's fine, unless you're scp'ing files that you didn't name.
â Alcuin Arundel
Jul 14 '16 at 4:46
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
6
down vote
accepted
Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:
scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .
All should work but some are syntactically easier to understand than others...
References:
- How to escape spaces in path during scp copy in linux?
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:
scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .
All should work but some are syntactically easier to understand than others...
References:
- How to escape spaces in path during scp copy in linux?
add a comment |Â
up vote
6
down vote
accepted
Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:
scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .
All should work but some are syntactically easier to understand than others...
References:
- How to escape spaces in path during scp copy in linux?
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:
scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .
All should work but some are syntactically easier to understand than others...
References:
- How to escape spaces in path during scp copy in linux?
Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try:
scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" .scp [remote username]@192.168.1.X:"/media/remote_username/photos 4/file.jpg" .scp [remote username]@192.168.1.X:/media/remote_username/photos\ 4/file.jpg .
All should work but some are syntactically easier to understand than others...
References:
- How to escape spaces in path during scp copy in linux?
edited Jun 12 at 10:28
answered Jul 14 '16 at 2:00
andrew.46
20.2k1463138
20.2k1463138
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f757824%2fhow-do-i-scp-a-filename-with-spaces%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Main lesson here: quit using spaces in file names. Even Apple corporation agrees on this now: support.apple.com/en-us/HT202808
â pauljohn32
Jul 14 '16 at 4:43
That's fine, unless you're scp'ing files that you didn't name.
â Alcuin Arundel
Jul 14 '16 at 4:46