Monday, May 6, 2024
55
rated 0 times [  55] [ 0]  / answers: 1 / hits: 138202  / 1 Year ago, thu, april 6, 2023, 5:30:27

I want to enter the following folder in the terminal:



Milano, Torino (Jan)-Compressed


How should I write the command cd to enter this directory?



Spaces and several other special characters like , *, ), ( and ? cause problems when I try to use them in the command line or scripts, e.g.:





$ cd space dir
bash: cd: space: No such file or directory

$ cat space file
cat: space: No such file or directory
cat: file: No such file or directory

$ cat (
bash: syntax error near unexpected token `newline'

$ echo content >
> ^C

$ ls ?
( ) * ?


How do I enter file or directory names that contain special characters in the terminal in general?


More From » command-line

 Answers
7

That command is ambiguous because spaces are normally used to separate arguments. cd does not know what you want to do but you have two possibilities to solve it:



Either you "mask" the spaces (and all other special characters) so that the terminal knows you mean the space as a character and not as a separator:



cd Milano, Torino (Jan)-Compressed


Or you put your folder name or path into quotes:



cd "Milano, Torino (Jan)-Compressed"

[#40551] Saturday, April 8, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ousear

Total Points: 395
Total Questions: 114
Total Answers: 89

Location: Jordan
Member since Thu, Aug 5, 2021
3 Years ago
ousear questions
Tue, Sep 27, 22, 03:29, 2 Years ago
Thu, Nov 25, 21, 00:51, 3 Years ago
Tue, Feb 22, 22, 17:47, 2 Years ago
;