LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-31-2007, 05:08 PM   #1
glenn69
Member
 
Registered: Jul 2003
Location: Chicagoland
Distribution: ArchLinux
Posts: 261

Rep: Reputation: 32
How do I scp a file with spaces in the filename?


I am trying to use scp to copy a file from work server to home as a backup.

The filename is RDC DATA FILE.txt with the spaces in the filename.

scp does not seem to recognize these. How do I scp this file?

thanks
 
Old 10-31-2007, 05:14 PM   #2
The_JinJ
Member
 
Registered: Apr 2004
Location: Scotland
Distribution: Suse, OpenWRT
Posts: 299

Rep: Reputation: 30
scp 'user@host:/Path/Some Filename With Spaces' [destination]
 
Old 10-31-2007, 07:43 PM   #3
glenn69
Member
 
Registered: Jul 2003
Location: Chicagoland
Distribution: ArchLinux
Posts: 261

Original Poster
Rep: Reputation: 32
Quote:
scp 'user@host:/Path/Some Filename With Spaces' [destination]
This did not work. scp thinks I am asking to copy 3 different files RDC then DATA then FILE.txt.
Any other ideas
 
Old 10-31-2007, 07:55 PM   #4
glenn69
Member
 
Registered: Jul 2003
Location: Chicagoland
Distribution: ArchLinux
Posts: 261

Original Poster
Rep: Reputation: 32
OK, trial and error prevailed. This is my solution:

scp 'user@host:/Path/"Some Filename With Spaces"' [destination]

Hope it helps someone
 
2 members found this post helpful.
Old 10-31-2007, 08:10 PM   #5
ludeKing
Member
 
Registered: Jul 2003
Location: NSW. Australia
Distribution: Ubuntu, Fedora, Slackware
Posts: 181

Rep: Reputation: 30
Quote:
Originally Posted by glenn69 View Post
I am trying to use scp to copy a file from work server to home as a backup.

The filename is RDC DATA FILE.txt with the spaces in the filename.

scp does not seem to recognize these. How do I scp this file?

thanks

Cant you just use backslashes to escape the space?

scp RDC\ DATA\ FILE.txt user@server:~
 
Old 10-31-2007, 09:35 PM   #6
glenn69
Member
 
Registered: Jul 2003
Location: Chicagoland
Distribution: ArchLinux
Posts: 261

Original Poster
Rep: Reputation: 32
Quote:
Cant you just use backslashes to escape the space?
I did try that, but the results were the same. It was trying to copy three separate files RDC then DATA then etc..
 
Old 10-31-2007, 11:34 PM   #7
igc35
LQ Newbie
 
Registered: Feb 2005
Location: Tasmania
Distribution: Fedora
Posts: 2

Rep: Reputation: 1
Quick emperical solution: Enclose the filename in single quotes _and_ escape the spaces with backslashes.

That seems like belt & braces, but it works for me.
 
1 members found this post helpful.
Old 11-01-2007, 02:55 AM   #8
nipunap
LQ Newbie
 
Registered: Mar 2007
Posts: 7

Rep: Reputation: 0
Smile keep black slash before the every spaces

Quote:
Originally Posted by glenn69 View Post
I am trying to use scp to copy a file from work server to home as a backup.

The filename is RDC DATA FILE.txt with the spaces in the filename.

scp does not seem to recognize these. How do I scp this file?

thanks

try this

scp RDC\ DATA\ FILE.txt <destination>

keep black slash before the every spaces

cheers,
Nipuna
http://nipunaperera.blogspot.com
 
Old 11-01-2007, 03:00 AM   #9
duryodhan
Senior Member
 
Registered: Oct 2006
Distribution: Slackware 12 Kernel 2.6.24 - probably upgraded by now
Posts: 1,054

Rep: Reputation: 46
Wouldn't BASH have done this for you through autocomplete when you pressed tab?
 
Old 11-01-2007, 03:55 AM   #10
JJX
Member
 
Registered: Mar 2004
Location: Greece
Distribution: Debian
Posts: 339

Rep: Reputation: 31
Yes, i use tab autocomplete to copy teh filename.
If u cant do this thet copy the file in a directory and send the directory
 
Old 11-01-2007, 04:04 AM   #11
TeodorescuM
LQ Newbie
 
Registered: Feb 2007
Location: Romania,Bucharest
Distribution: CentOS
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by glenn69 View Post
I am trying to use scp to copy a file from work server to home as a backup.

The filename is RDC DATA FILE.txt with the spaces in the filename.

scp does not seem to recognize these. How do I scp this file?

thanks

if you are copying the file from home:
scp user@host:path"RDC\ DATA\ FILE.txt"

example :
you want to copy the file from machine1 to machine2 , being on machine2; the file is located on machine1 in /home/user1/mydir/
syntax:
scp user1@machine1:/home/user1/mydir/"RDC\ DATA\ FILE.txt" destination

Last edited by TeodorescuM; 11-01-2007 at 04:14 AM.
 
Old 11-01-2007, 04:33 AM   #12
sKaar
Member
 
Registered: Jun 2006
Location: dartmouth, nova scotia
Distribution: slackware 12.1
Posts: 74

Rep: Reputation: 2
the backslash thing, RDC\ DATA\ FILE.TXT, and quotes "RDC DATA FILE.TXT", they both work for me with the bash that comes with slack, haven't tried both at the same time. i figure, if it works, you don't need to whip it.
 
Old 11-01-2007, 04:44 AM   #13
ankur.dhoot
LQ Newbie
 
Registered: Oct 2007
Posts: 1

Rep: Reputation: 0
Just do it....

Quote:
Originally Posted by glenn69 View Post
I am trying to use scp to copy a file from work server to home as a backup.

The filename is RDC DATA FILE.txt with the spaces in the filename.

scp does not seem to recognize these. How do I scp this file?

thanks
You just do scp with filename having spaces as:

scp RDC\ DATA\ FILE.txt user@IP:
 
Old 11-01-2007, 07:04 PM   #14
kevinator
LQ Newbie
 
Registered: Aug 2001
Posts: 3

Rep: Reputation: 0
You have escape the space and backslash.

scp RDC\\\ DATA\\\ FILE.txt user@IP:
 
Old 11-01-2007, 07:18 PM   #15
glenn69
Member
 
Registered: Jul 2003
Location: Chicagoland
Distribution: ArchLinux
Posts: 261

Original Poster
Rep: Reputation: 32
Quote:
You have escape the space and backslash.

scp RDC\\\ DATA\\\ FILE.txt user@IP:
Yep this works too. Thanks
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script: lame stumbles on spaces in filename browny_amiga Linux - General 5 05-14-2008 08:14 AM
bash, cp and filename (with spaces) woes dfidler Programming 9 04-10-2007 11:12 PM
XMMS brakes titles if filename contains spaces? deftone` Linux - Software 0 01-13-2007 05:05 AM
Getting rm to like spaces in filename kyosuke Linux - General 2 02-28-2006 04:55 PM
spaces in filename in console...? AlThor880 Linux - Software 4 01-09-2003 02:36 PM


All times are GMT -5. The time now is 06:46 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration