Handle space in directory name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Handle space in directory name
# 1  
Old 06-14-2013
Tools Handle space in directory name

I have two servers in subject, say server1 and server2. I have shell scripts on server1. We have a directory on server2 from where the files need to be scp to server1.

The directory on server2 is having space in its name.

I have script on server1 that takes the directory path of server2 as a parameter and scp the file from server2 to server1. I am unable to supply the directory path of server2 as an input to the shell script on server1.

Need assistance to nullify the space in the directory name.

Have tried to use the \ slash once , twice, thrice...all the efforts failed.

Help needed.

Last edited by Longfellow; 06-14-2013 at 02:44 PM..
# 2  
Old 06-14-2013
Try enclose it in double quotes.
# 3  
Old 06-14-2013
Or single quotes, or use ? where the space occurs.
# 4  
Old 06-14-2013
The most universal is:-

Code:
cd "/full/path to/some drawer/with spaces/"<CR>

Note the inverted commas.

This method works on Linux/UNIX, OSX, AMIGAOS and Windows...
# 5  
Old 06-14-2013
I guess you have to switch to sftp or ssh to cd. I recall that sometimes with ftp I had to cd to the desired dir one level at a time, but then transfers would work that were not working with slashes. And of course if you can scp you can ssh, where the quoting may work more reliably.
Code:
ssh id@host 'cat "/a/b c/d/e/f" ' >"/a/b c/d/e/f" 
 
and 
 
ssh id@host 'cat >"/a/b c/d/e/f" ' <"/a/b c/d/e/f"

Attributes and times not preserved.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

To handle the case during copy when: No space left on device

print "After create SubDir routine."; createSubDirs($fileDir); my $from = $ORACLE_HOME.$dirSep.$file; my $to = $bootstrapDir.$dirSep.$fileDir; if ($isWindows) { copy($from,... (2 Replies)
Discussion started by: ambarginni
2 Replies

2. Shell Programming and Scripting

To handle the case during copy when: No space left on device

print "After create SubDir routine."; createSubDirs($fileDir); my $from = $ORACLE_HOME.$dirSep.$file; my $to = $bootstrapDir.$dirSep.$fileDir; if ($isWindows) { copy($from,... (1 Reply)
Discussion started by: ambarginni
1 Replies

3. UNIX for Dummies Questions & Answers

Difference between handle to the thread HANDLE and thread identifier pthread_t

This question might be silly but its confusing me a bit: What is the difference between handle to the thread HANDLE and thread identifier pthread_t? ---------- Post updated at 01:52 PM ---------- Previous update was at 01:48 PM ---------- Sorry I saw details and HANDLE is in windows and... (0 Replies)
Discussion started by: rupeshkp728
0 Replies

4. Homework & Coursework Questions

Read text, handle white space

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: The problem would be to make the program tolerate the white space and still read the string of characters. the... (1 Reply)
Discussion started by: mgyeah
1 Replies

5. UNIX for Dummies Questions & Answers

Display all directory/sub directory with occupied space?

Hello, I am using Red Hat linux system. I see my /work directory has used space 300GB. But there are so many sub directory under /work. I want to list each direcotry and under all subdirectory. But i want to know how much space occupied by each directory. What kind of command i can use to... (3 Replies)
Discussion started by: govindts
3 Replies

6. Red Hat

/boot directory out of space

We applied updates on saturday and noted that we have used 97% of our /boot directory. How can I tell what files i can keep or get rid of in this directory? or how can I increase the size of this partition. Red Hat Enterprise Linux ES release 3 (Taroon Update 9) 2.4.21-57.ELsmp Thank... (4 Replies)
Discussion started by: redac
4 Replies

7. Red Hat

can not reboot : PCI: Unable to handle 64-bit address space for

Hello, every one, I tried to install redhat linux enterprise server version 4 (ES4) on the my system with the following configuration Pentium core 2 duo 2.66 E 6750 Intel DG33FB motherboard 160Gb Segate hard disk (SATA) 1024 mb (1GB) DDR2 TRAN RAM Lg DVD/Cd WR BUT AM GETTING... (0 Replies)
Discussion started by: moinkhan31
0 Replies

8. Filesystems, Disks and Memory

Space Used by Directory Tree

Can someone tell me how I can determine how much space (blocks) have been used by a given directory tree? I periodically need to know how much space is consumed by a directory and all of its files and subdirectories and their files in either KB or blocks. I have tried df and du but these do not... (1 Reply)
Discussion started by: johnk99
1 Replies

9. Shell Programming and Scripting

Check directory space?

Is there some command I can use to check to see if there is 2 Gig of space available in a directory before I created a 2 Gig file? (3 Replies)
Discussion started by: lesstjm
3 Replies

10. UNIX for Advanced & Expert Users

Space in the directory name

I've got a small script that deletes all the trash from mailusers Trash directory. I run this script once in a while to make some space. (We have lots of IMAP users, who keep their mail on server!) Occansionaly, the users create directories with space in the name (e.g. "My Mail"). And sometimes... (5 Replies)
Discussion started by: nitin
5 Replies
Login or Register to Ask a Question