Shell Script to Enter a Directory (Folder Name Contains Spaces)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script to Enter a Directory (Folder Name Contains Spaces)
# 1  
Old 11-02-2012
Linux Shell Script to Enter a Directory (Folder Name Contains Spaces)

I am writing a shell script to cd to a folder.
folder name is "October Scripts"
I am currently storing the name of folder in a shell variable as so path="October\ Scripts/".
If I do cd $path I receive the error bash: cd: October\: No such file or directory

What am I doing wrong?
Kindly help
# 2  
Old 11-02-2012
Code:
path="October Scripts"
cd "$path"

# 3  
Old 11-02-2012
no need give backslash there..

just use double quotes..

Code:
path="October Scripts/"
cd "$path"

# 4  
Old 11-02-2012
Thank you pamu and elixir_sinari,

Pamu your code worked,
Thanks a lot Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

3. UNIX for Advanced & Expert Users

Problem with shell script while spaces encountered in directory names

Hi, I am having issues with the jar -tf command when I put in the shell script. The command runs fine from the command line as shown below. # jar -tf "./VirtualBox Dropped Files/2016-04-17T20:58:49.129139000Z/hive-exec-0.8.1.jar" But when I put in a shell script(shown below) and the... (10 Replies)
Discussion started by: vinoo128
10 Replies

4. Shell Programming and Scripting

Shell Script for enter folders and join file

Hello everyone. I have a dlink cam that save recordings splitted for hours. Each hour folder contain a lot of small avi files. Repository has the following directories structure: \_20140101/ \_ 01 \_a.avi \_b.avi \_ 02 \_c.avi ... (3 Replies)
Discussion started by: setterx
3 Replies

5. Shell Programming and Scripting

Simulating enter key via shell script

How to simulate enter key via shell script (2 Replies)
Discussion started by: proactiveaditya
2 Replies

6. Shell Programming and Scripting

Unique Directory and Folder Deletion Script

Ok, so I just got charged with the task of deleting some 300 user folders in a FTP server to free up some space. I managed to grep and cut the list of user folders to delete into a list of one user folder per line. Example: bob00 jane01 sue03 In the home folder, there are folders a-z, and... (5 Replies)
Discussion started by: b4sher
5 Replies

7. Shell Programming and Scripting

How to catch ENTER key inside the shell script?

Hi, I have a script in which i have to ask user to press the ENTER key to proceed further. can you please help me how can i achive this in my scripting? echo "All the executables builded Successfully " echo " Press Enter to Go Back to the Main Menu" ... (2 Replies)
Discussion started by: plaban.rout
2 Replies

8. Shell Programming and Scripting

Enter Crtl+U character in shell script

hi I have some program which accepts "Crtl+U" input, Now i want to run it thorugh my written script ...all other inputs are accepted but how to supply this input. I am supplying input parameters to the program named EX as below. ================================= main.sh . . EX<<EOF... (3 Replies)
Discussion started by: ashish_uiit
3 Replies

9. Shell Programming and Scripting

writing Enter key inside in shell script

for automating telnet using shell script..... as we enter alphabetic characters inside shell script...how can we do the same for the enter key......Is there any character for the enter key so the enter key need not be pressed manually...... (3 Replies)
Discussion started by: bishweshwar
3 Replies

10. UNIX for Advanced & Expert Users

using enter key in shell script

without pressing the enter key ..manually... how can we read the enter key ..from the shell script..so that the script termintes automatically. eg: telnet a.b.c.d xxxx now " how to read the enter key" tho terminate the script (1 Reply)
Discussion started by: bishweshwar
1 Replies
Login or Register to Ask a Question