What does this command do? "$HOME/path/to/the/Folder/"

Hi,


What does the following command do?


$HOME/path/to/the/Folder/TEMP


If the TEMP file does not exist, will it create a new TEMP folder?


How can I check whether a "new TEMP folder" is created?


Thanks in advance.


Ed

Posted on Jun 27, 2014 1:40 AM

Reply
12 replies

Jun 28, 2014 11:15 AM in response to EDLIU

>>Is it correct that if the .DS_Store does not exist, it will create a new .DS_Store file?

Only if path/to/the/Folder exists within your home folder and you save to it while using nano, but you don't need sudo for something in your home folder.


You'd be better off saying what you want to achieve, rather than following Terminal commands which may cause problems.

Jun 28, 2014 5:35 PM in response to EDLIU


What does the following command do?

$HOME/path/to/the/Folder/TEMP


If the TEMP file does not exist, will it create a new TEMP folder?

How can I check whether a "new TEMP folder" is created?



As said, this is not a command, so a directory will not be created.

(If you want to create a new directory, use mkdir (or better yet, just use Finder->File->New Folder))

$HOME is the variable that holds your Home Directory, same as the shortcut ~

Enter echo $HOME and you will see your home directory.

To see if the Folder was created, use cd (or Finder)

Jun 28, 2014 5:58 PM in response to EDLIU

I entered the command "sudo nano $HOME/path/to/the/Folder/.DS_Store"

$HOME is your home folder, where all your stuff is stored, such as your Pictures, Music, Movies, Documents, etc... HOME is an environment variable set when you start the Terminal session, and the $ is the substitution operator that tells the shell (in the case bash, or Bourne Again SHell) that it should lookup the value of variable HOME, and replace the string $HOME with the value stored in HOME. On Mac OS X HOME typically looks like /Users/yourShortUserName


$HOME/path/to/the/Folder is a filling for "YOU" to specify the set of directories under your Home Folder that lead to the .DS_Store file you were interested in from another thread where you were trying to reset the folder size and screen location (I recognize the /path/to/the/Folder notation as being something I like to write when I do not know what directory path the file in question is located at).


Now $HOME/path/to/the/Folder/ is NOT a command. As I said, it was a way to indicate that you filling the information that ONLY you know, namely where is the file you are trying to work on.


sudo is a dangerous command, as it grants the program running the power of 'root', and on any Unix based system 'root' is the absolute power, it is unrestricted in what it can do, and in the wrong hands, 'root' can destroy a system, or corrupt it, or do magical wonderful things.


nano is a text editor that runs in a character cell terminal emulator, such as Applications -> Utilities -> Terminal (there are other terminal emulators available). sudo nano runs nano as the root user, so nano can edit any file regardless of the files permissions, and/or create a text file anywhere on the system regardless of the permissions of the parent folder (but this is ONLY when nano is invoked via sudo, otherwise, nano is just a normal text editor and is subject to all the permissions restrictions of the user running the command.


sudo nano $HOME/path/to/the/Folder/.DS_Store would attempt to edit a .DS_Store file, if it existed, or create a .DS_Store file if the directory exists AND nano was giving the commands to write its contents. In this case if you literally specified the file as $HOME/path/to/the/Folder/.DS_Store, then it is unlikely you have a sub-folder called 'path' in your home folder, and it even less unlikely you have a sub-sub-folder 'to' in the 'path' sub-folder, and it is extremely unlikely that you have a 'the' sub-sub-sub-folder in the 'to' sub-sub-folder, and the odds are off the charts if you have a sub-sub-sub-sub-folder 'Folder' in the sub-sub-sub-folder 'the'. But if all of those unlikely folders nested in each other exist, then there would be a good chance there is a .DS_Store located there, so congratulations, you just opened a binary file in a text editor and it looks like a lot of ^@ character pairs with an occasional small string of letters that almost look like something. If you modified this binary file using nano, the likely hood is you messed it up, and it should be deleted to allow the Finder to create a new on. HOWEVER, I'm fairly confident you do not have a literal $HOME/path/to/the/Folder/.DS_Store folder sequence and thus no damage of any kind was done.

Jun 29, 2014 6:10 AM in response to EDLIU

So "$HOME/path/to/the/Folder/.DS_Store" will fill in the "path" that the .DS_Store is stored?

You fill in the path. That is to say, we do not know the folder you are interested in. And since there are thousands of folders (hundreds of thousand) on the Mac, the computer will not fill it in either. ONLY "You" know where the folder you are interested in lives. So you replace "path/to/the/Folder" with the correct information. Until then "path/to/the/Folder" is a place holder, and a way for me to give you the general idea of how to specify the path, without my actually knowing where the desired folder lives.


You build a path by stringing folder names together, separated by a forward slash / and if there are any spaces or punctuation characters in the folder names, you protect the full path name by enclosing it in quotes, 'stuff to protect goes in here'.


The option is to get out of the Terminal and forget it ever existed. 99.9999999% of Mac usage does not need the Terminal, and generally it is ancient programmers that grew up when 80 column punched cards were how you communicated with computers. That generation thinks a Terminal is advanced technology, and having noticed that the computer industry has moved on (and yes, I am one of them, and I actually make my living still using terminal emulators, but the rest of the world has moved on).


BTW, is it right that the "." will make the file "hidden"?

A file with a leading period in its name is a long standing convention from back in the '70's on Unix platforms that by default the 'ls' (list) command would not display files that started with a leading period unless' ls -a' was used. This was a way to put config files in a users home directory, but not clutter up the 'ls' output with things most users did not care about on a day-to-day basis. Over time, it was adapted as a way to hid files. The Mac "Finder" took up treating files with leading periods as hidden files.

The Mac "Finder" has other ways to indicating a file should be hidden via a "hidden" file attribute, which is used to hide standard system folders that users should not be playing with, such as the operating system files. Most Mac users never see them and do not care.


Can I check whether the directory or file exist from the Finder -> Mac HD or Finder -> Home?

If the file or folder does not have a leading period or the above mentioned hidden file attribute, the Finder can display, if you can navigate to the file or folder. Finder -> Go -> "Go to Folder..." can get you anywhere, assuming you can enter the /path/to/where/you/want/to/go/notation, or at least the beginning to get you started. Just entering / all by itself will put you at the top of the file system (called the root directory).


However, if a file or folder is hidden, the Finder will not display it, unless you play games with Finder hidden features that takes you back to Terminal commands and/or 3rd party utilities that can enable the Finder show all files mode.


NOTE: If you go exploring outside your home folder, please do not modify or delete things, or you could turn your Mac into a "Door Stop". A "Pretty", but very expensive "Door Stop".

Jun 29, 2014 6:35 AM in response to EDLIU

Can I check whether the directory or file exist from the Finder -> Mac HD or Finder -> Home?

BTW, is it right that the "." will make the file "hidden"?


[Edit: I Just saw that Bob gave a much better explanation]


In Finder, use ~, so to change to the Documents Folder in your Home Folder:

Finder->Go->Go to Folder

Enter: ~/Documents

For a File, Enter: ~/Documents/filename.txt


Yes, "." will make the file hidden to Finder, so you cannot (by default) view hidden files in Finder.

To view a hidden file in Terminal:

cd ~/Documents

ls -a filename.txt ( i.e. ls -a .DS_Store. For all files in directory: ls-a )


You can also search for a file in Terminal with:

find ~ -iname ".DS_Store"

Wildcards can be used:

find ~ -iname "*.txt"

To search just the Documents Folder:

find ~/Documents -iname "*.txt"

(~ searches your home folder, ~/Documents the Documents Folder on your home folder)

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.

What does this command do? "$HOME/path/to/the/Folder/"

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