terminal cd command

if your file name has a gap like "File 1" when u try to go to this directory by cd File 1. it shows an error (cd: string not in pwd:)

MacBook Air 13″, macOS 12.2

Posted on Aug 11, 2023 1:31 AM

Reply
Question marked as Top-ranking reply

Posted on Aug 11, 2023 6:54 AM

In zsh and bash shells, vertical (not angled) double quotes are required around strings containing embedded spaces.


hhttps://unix.stackexchange.com/questions/131766/why-does-my-shell-script-choke


https://unix.stackexchange.com/questions/131766/why-does-my-shell-script-choke-on-whitespace-or-other-special-characters


etc

4 replies

Aug 11, 2023 9:08 AM in response to Avinash_deshmukh

In the Terminal, when you want to change directory to a folder whose name contains white-space, you can do the following path completion if you don't want to manually escape the space. You replace the angle-bracket tab notation with a single tab key press, and the next line is what the shell updates on the same line. Then press return and you enter that space punctuated folder.


cd File<tab>
cd File\ 1/


The Finder is happy with any character except ':' and in the Terminal where UNIX lives, there are certain characters (including white-space) that must be escaped from the shell.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

terminal cd command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.