To cd to a directory with spaces in the name, in Bash, you need to add a backslash ( \ ) before the space. In other words, you need to escape the space.
How do I add a space in Mac terminal?
Click and drag the space where you want it and release. To add another space, run the Terminal command again. Then drag the second space where you want it. If you decide later to remove the spaces you’ve added, just click and drag them out of the Dock.
How do you use a cd command on a Mac?
Use cd to visit the directory
- Use cd to visit the directory.
- Enter “cd directory name” in the Terminal window, replacing “directory name” with the name of the directory on your computer.
- Return to the previous directory.
- Type “cd -” in the Terminal window and press “Return.” The Terminal returns to the previous directory.
How do I navigate a cd in terminal?
cd or change directory The cd command allows you to move between directories. The cd command takes an argument, usually the name of the folder you want to move to, so the full command is cd your-directory . Now that we moved to your Desktop, you can type ls again, then cd into it.
How do I use the cd command with two arguments?
The cd command typically requires exactly one argument (the destination directory). A command line like cd foo bar means to run cd with two arguments: foo and bar. If you only wanted to send a single foo bar argument, then you need to quote the space:
How do you run a command in terminal on a Mac?
Basic Mac commands in Terminal The quickest way to get to know Terminal and understand how it works is to start using it. But before we do that, it’s worth spending a little time getting to know how commands work. To run a command, you just type it at the cursor and hit Return to execute.
How do I handle spaces in file and directory names?
Because Finder allows spaces in file and directory names, I’m often creating such with spaces but then if I try to cd to one in the Terminal the space kills the command. How is this done?” There are three ways that I know of to handle this. They are: Drag-and-drop the file or directory onto the terminal; this will preserve the spaces.
How do I escape whitespace in a folder using the terminal?
Escape the whitespace with \\ like this: Or just drag and drop the folder into the Terminal. But why don’t you just type a few characters and press Tab for auto-completion? The shell performs word splitting on arguments before passing it them to the command you specify.