Why directory name is not recognized from Terminal window, but is recognized from my MacBook Air desktop?

Can anybody help me to understand, what is going on, please?

I have created a folder on my Desktop and put subfolders inside with individual files  (HideIt is the name of this folder). 

I  close  HideIt folder.

I  open   HideIt folder again. 

I can see the files, copy them, close , delete. No problems.

Now I open  Terminal utility

I  can see my desktop

when i type “ ls -l “ ,  I see the following:   drwx------@ 14 grigoryzubkis  staff     448 Jun 11 02:53 Desktop

I type “ cd Desktop”, 

type “ ls -l “ I see the following: drwxr-xr-x@ 28 grigoryzubkis staff 896 Jun 10 09:27 HideIt 

I try to step down into HideIt directory “ cd Hideit “, but get back: “ cd: no such file or directory: Hideit”

Why is that? Why      “ ls -l “ does show me directory, but when I try to step down into this directory  “ cd Hideit “, it doesnot work?

I try another thing. Instead of typing “ cd Hideit “,     I type “ cd Hide* “, and it works?

What is going on?????

Also when somehow I try to copy or delete or whatever files inside “ HideIt “ folder  , It does not work?

But if i do it just from my desktop, but not from Terminal utility,  it does work?

Any help is greatly appreciated.



MacBook Air 13″, macOS 12.4

Posted on Jun 11, 2022 5:52 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 11, 2022 5:58 AM

Do you have a case-sensitive file system? Your folder is named HideIt but you asked Terminal to change to Hideit.

From Desktop as the working folder, try typing Hi then tab key. It should expand out the full name of the folder. When it does, try entering the command.

5 replies

Jun 11, 2022 6:47 AM in response to BobHarris

Thanks a lot!

You are absolutely right!!!!

I have a trailing space at the end of directory name . So, directory name is not "HideIt", but "HideIt " !!!!


Another question:

when i use " cp " comand to copy complete directory to another direcory , how do I specify directory name?

Or if the source directory name is "Folder greg" (with space embedded between "Folder" and "greg" , how must my "cp" command look like?

Thanks a lot for help.


Jun 11, 2022 8:57 AM in response to grigory193

spaces in file names and folders.


If you are going to be working from the command line a lot, then when you are naming a file or folder, just use _ (Underscore) where you would put a space, and your life in the command line will be easier.


Where you do not have control, or should not change a name macOS created, then you either single quote, double quote or backslash quote the name


Folder greg

would be specified on the command line as one of the following:

"Folder greg"
'Folder greg'
Folder\ greg


You can drag and drop a file or folder from the Finder to the Terminal window, and it will be properly quoted for use.


Copying a directory


cp -rp /path/to/directory/to/be/copied  /path/to/parent/directory/


So if I have a directory $HOME/Downloads/Fred and I want to make a copy in the parent directory $HOME/Documents, I would enter:

 cp -Rp  $HOME/Downloads/Fred  $HOME/Documents/

OR

cd $HOME/Downloads
cp -Rp Fred  $HOME/Documents/

Or

cd $HOME/Documents
cp -Rp $HOME/Downloads/Fred  ./


The -R will is for recursive and it will make sure all subdirectories under Fred are copied as well.

The -p is so that file permissions are preserved.

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.

Why directory name is not recognized from Terminal window, but is recognized from my MacBook Air desktop?

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