if i need to go to my directory named as"exception handling" then i write (cd exception handling) but it gives error too many arguments
Asked
Active
Viewed 2e+01k times
38
-
8Either put the file name in quotes or escape the spaces so that `bash` knows it's one string: `cd 'long file name'` or `cd long\ file\ name`. The problem is not unique to Ubuntu. If you were in a Windows command shell you'd have the same issue. – lurker Nov 17 '17 at 13:41
-
The problem is unique to bash 4.4; its implementation of "cd" is buggy. The manual page bash(1) specifies that " Any additional arguments following dir are ignored." The OP's command should go to directory "exception" and ignore "handling". Instead it throws an error. This is a bug. I tried bash 4.2, where "cd" works correctly. – Quigi Apr 07 '21 at 18:09
1 Answers
105
Use quotes:
cd "new folder"
or escape the space:
cd new\ folder
(That being said, cd
does not open a file but changes the working directory.)

Sora.
- 1,395
- 1
- 11
- 14
-
-
Can this be saved in variable or alias? E.g. NF="new\ folder"; cd $NF – Joonho Park Aug 19 '22 at 07:45