bash : cd : too many arguments [closed]
Asked Answered
A

1

39

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

Atypical answered 17/11, 2017 at 13:38 Comment(2)
Either 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.Narton
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.Salyers
A
110

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.)

Andromeda answered 17/11, 2017 at 13:41 Comment(2)
This is what I was looking forProjectile
Can this be saved in variable or alias? E.g. NF="new\ folder"; cd $NFAmalia

© 2022 - 2024 — McMap. All rights reserved.