Cd too many arguments что делать
Перейти к содержимому

Cd too many arguments что делать

  • автор:

bash : cd : too many arguments [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Closed 4 years ago .

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

Veerabala J
asked Nov 17, 2017 at 13:38
Veerabala J Veerabala J
563 1 1 gold badge 5 5 silver badges 14 14 bronze badges

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.

Nov 17, 2017 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.

Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash: cd: too many arguments #8110

Cd too many arguments что делать

Last updated: Mar 22, 2023
Reading time · 3 min

banner

# Table of Contents

  1. cd: too many arguments error in Bash and ZSH
  2. Wrap the name of the directory in double quotes
  3. Use a backslash to escape the spaces
  4. Use the Tab key for auto-completion
  5. Open your terminal in the destination directory

# cd: too many arguments error in Bash and ZSH [Solved]

The «cd: too many arguments» error in bash and zsh occurs when we try to cd into a directory whose name contains spaces or special characters.

You can solve the error by wrapping the directory name in double quotes or by using a backslash to escape each space.

cd too many arguments in bash zsh

Here is an example of a command that causes the error.

Copied!
cd my new folder

We a trying to cd into a directory whose name contains spaces, so bash assumes that we are passing multiple, space-separated arguments to the cd command.

You might also get the error «cd: string not in pwd:» when you try to cd into a path that contains spaces.

Copied!
# ⛔️ cd: string not in pwd: cd my folder

cd string not in pwd

The solution to both errors is the same.

# Wrap the name of the directory in double quotes

One way to solve the error is to wrap the name of the directory in double quotes.

Copied!
cd "my new folder"

example of command that causes error

You can also wrap an entire path to the directory in quotes.

Copied!
cd "my folder/my nested folder"

wrap entire path to directory in quotes

You can also wrap only the path components that contain spaces or special characters in quotes.

Copied!
cd my_folder/"my nested folder"

wrap only necessary path components in spaces

# Use a backslash to escape the spaces

You can also resolve the error by using a backslash to escape each space in the path.

Copied!
cd my\ new\ folder

using backslash to escape each space

Backslashes are used to escape special characters, so they can be treated literally.

For example, escaping a space with a backslash means «Treat the space as a literal space character and not as a separator between arguments».

Using this approach is a bit tricky because each space has to be escaped by a backslash.

It also gets a bit difficult to read when the path is deeply nested.

Here is an example.

Copied!
cd bobbyhadz-js/my\ new\ folder

backslash escape nested path

I used a forward slash / as the separator between the path components and then used a backslash \ to escape each space.

# Use the Tab key for auto-completion

You can also solve the error by using Tab auto-completion:

  1. Start typing the path.
  2. Press the Tab key to get auto-complete directly in your terminal.

Here is a short clip that demonstrates how this works.

If you have multiple folders with similar names, you might have to type the first few characters of the name to identify the correct folder you want to cd into.

If you don’t get autocomplete when you start pressing Tab , then the specified path doesn’t exist.

# Open your terminal in the destination directory

If you still aren’t able to cd into the directory, you can open your terminal directly in the destination folder.

For example, on Linux, you can:

  1. Open the directory in explorer.
  2. Right-click and select Open in Terminal.

open folder in terminal linux

Here is a short clip that demonstrates how this works.

On macOS, you can:

  1. Open a Finder window and navigate to the folder.
  2. If you don’t see the path bar at the bottom of the Finder window, choose View -> Show Path Bar.
  3. Press Ctrl and click the folder in the path bar.
  4. Select Choose Open in Terminal.
  1. Open the folder in Finder.
  2. Click on Finder in the top menu, then hover over Services.
  3. Select New Terminal at Folder.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

  • cd: no such file or directory error in Bash and ZSH [Fixed]
  • bash: permission denied: /home/user/.bashrc error [Solved]
  • Ubuntu: An error occurred. The specified movie could not be found
  • Unable to update «Snap Store»: Cannot refresh «snap-store»

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.

How to Solve cd: Too Many Arguments Error in Bash

How to Solve cd: Too Many Arguments Error in Bash

We use the cd command to change the working directory in Linux. However, incorrect use of this command may cause an error.

This article will explain how to solve the bash: cd: too many arguments error in Linux Bash.

Solve bash: cd: too many arguments Error in Bash

The cd command accepts a directory name as an argument and replaces the current shell environment’s working directory with the given directory.

If no argument is given, the cd command behaves as if the directory named in the HOME environment variable was specified as the argument.

If the directory you want to go to consists of more than one word and contains spaces, you should not give it an argument directly. The command below will generate the bash: cd: too many arguments error.

cd test directory 

The command accepts test and directory as separate arguments and cannot operate. To solve this problem, you must write the directory name in quotation marks; use single or double quotes as you wish.

The following command will run without error, and the current directory will be replaced with the test directory . Using a slash ( / ) after the directory name is optional.

cd "test directory/" 

Another way to do this is to use the backslash character. The backslash ( \ ) is an escape character, and it preserves the literal value of the next character that follows.

So you can use the space character.

The following command will also run without error, and the current directory will be replaced with the test directory . Using a slash ( / ) after the directory name is optional.

cd test\ directory/ 

Yahya Irmak has experience in full stack technologies such as Java, Spring Boot, JavaScript, CSS, HTML.

Related Article — Bash Error

  • How to Handle Errors in Bash
  • How to Solve Error: Make Command Not Found on Cygwin
  • How to Solve Nodemon Command Not Found
  • How to Solve R Command Not Found on Bash (Or Cygwin)
  • How to Fix the Mkvirtualenv Command Not Found Error in Bash
  • How to Solve Syntax Error Near Unexpected Token in Bash

Copyright © 2024. All right reserved

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *