0

I am trying to navigate the bash command line to a subdirectory of my /projects directory, and I keep getting 'No such file or directory'.

The ls command clearly shows the directory in existence.

What am I missing?

Note: I am trying to navigate to the directory to run npm tests, if that context matters :)

enter image description here

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
RoryH
  • 111
  • 1
  • 6
  • `cd 'Content Creator'` or `cd Content\ Creator` although a tab-complete of the directory should do too. `cd C` – Jetchisel Mar 30 '20 at 00:41
  • 3
    Since your prompt shows "MBP", this was asked and answered over at AskDifferent: [How to access a folder which name is composed of more than 1 word via shell?](https://apple.stackexchange.com/q/146006/253138) – Gino Mempin Mar 30 '20 at 00:42

2 Answers2

1

This may be due to the space in your directory name. You can either rename it for easier access or just start writing the name and use autocompletion (with tab) to let the system write it properly for you. If the above solutions still don't work, try to escape the space with a backslash (Content\ Creator) to see what happens.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
iceberg53
  • 330
  • 1
  • 7
1

You may try to put quotation marks around 'Content Creator' like that.
When you try to navigate to any directory, it is better you always use quotation marks even there is no space character. Because it could have similarity with a command. To prevent any trouble.

Muhammed
  • 96
  • 3
  • 8
  • 1
    I agree with you but using space is a common habit in directory names. – Muhammed Mar 30 '20 at 00:58
  • 5
    @GinoMempin, ...blaming incorrect handling on the data being handled isn't a useful approach -- it doesn't *fix the code* that isn't robust enough to handle all possible values. Sometimes data comes from outside your control -- sometimes it's even generated by a deliberately malicious attacker. The Right Thing is to write code that's correct *no matter what your data is*; otherwise when a bug creates a filename with a whitespace-surrounded `*` in it, you might find yourself like one of my former employers did -- with all their backups deleted because a script tried to delete that one file. – Charles Duffy Mar 30 '20 at 01:05
  • @CharlesDuffy Good point on "*write code that's correct no matter what your data is*". I failed to consider the situation when the directory name is supplied from external sources. – Gino Mempin Mar 30 '20 at 01:09