Unable to access created file or folder from terminal

Asked by Lorenzo on 2014-05-18

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

Language:
English Edit question
Status:
Solved
For:
Ubuntu gnome-terminal Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
2014-05-20
Last query:
2014-05-20
Last reply:
2014-05-19
Manfred Hampl (m-hampl) said : #1

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

Try

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

Lorenzo (lojay397) said : #2

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.

Best Manfred Hampl (m-hampl) said : #3

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.

Lorenzo (lojay397) said : #4

Thanks Manfred Hampl, that solved my question.