Unable to access created file or folder from terminal

Asked by Lorenzo

With the file manger I created a folder (SPELL CK) and file (spell test) in which, I created a doc with gedit and placed in the folder. All was done in my home directory. From the terminal I ran: cd /home/lorenzo/SPELL CK and got the output ...no such file or directory, I did like wise for the file spell test, resulting in the same . However, when I ran: cd /home/lorenzo/Music or Pictures, I got the output /Music or /Pictures. It's like the terminal sees ubuntu's created files and folders but not mine.

Can someone please help me with this.

Question information

English Edit question
Ubuntu gnome-terminal Edit question
No assignee Edit question
Solved by:
Manfred Hampl
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :

The root cause seem to be the space character in the file name.


cd /home/lorenzo/SPELL\ CK
cd "/home/lorenzo/SPELL CK"
and so on.

Revision history for this message
Lorenzo (lojay397) said :

This (^) means a (space) and it was as you suggested: cd^"/home/lorenzo/SPELL^CK" , a long with (") output: $/SPELL CK...Many thanks but before I click problem solved could you please tell me why it was necessary to use the (") character in accessing my created folder or file but not in ubuntu's.

Revision history for this message
Best Manfred Hampl (m-hampl) said :

For the command interpreters white space (e.g. a space character) works as separator between parameters and/or options

So the command 'cd /home/lorenzo/SPELL CK' is broken into
cd ... command
/home/lorenzo/SPELL ... first parameter
CK ... second parameter (probably ignored by the cd command)

Thus the system is trying to change directory to "/home/lorenzo/SPELL" which does not exist.

What you need is to activate a mechanism that disables the interpretation of that space character inside the directory name as a separator.
The following possibilities should work:
1. put a backslash in front of the space character: cd /home/lorenzo/SPELL\ CK
2. enclose the file/directory name in single quotes: cd '/home/lorenzo/SPELL CK'
3. enclose the file/directory name in double quotes: cd "/home/lorenzo/SPELL CK"

There is another function that might come handy in such context - file name expansion with the tab key:
If you open a terminal and enter the following text
cd SPE<Tab>
(that is entering the characters "cd SPE" and then hitting the TAB key on your keyboard), then the command interpreter should expand SPE to the full file name (with escape characters), if there is only one file/directory that starts with SPE.

Revision history for this message
Lorenzo (lojay397) said :

Thanks Manfred Hampl, that solved my question.