There are two lines and I don't understand them. Please explain in detail, I'm a very new Linux user.
$ export ML_PATH="$HOME/ml"
$ mkdir -p $ML_PATH
Secondly, I made a folder on my desired destination. Then opened the terminal there, and typed these commands. And nothing seemed happen. The command line just skipped to get a new command.
Hi @SM-Fahim ,
Thanks for your questions!
The first $ sign on each line is just there to indicate that the rest of the line is a command that should be typed in a shell (i.e., a Terminal window running a shell program such as Bourne Again Shell = bash, or zsh). Do not type the first $ on each line.
The export keyword is used in a shell to define an environment variable. In this case, we are defining the ML_PATH environment variable to be equal to the value of the HOME environment variable followed by /ml. The HOME env variable is usually automatically defined by your system to be equal to the path to your home directory, which is typically /home/your_login. So typically the first line will result in defining the env variable ML_PATH to be equal to /home/your_login/ml (or /Users/your_login/ml on MacOSX).
The second line uses the mkdir command to create the directory whose name we just defined in the ML_PATH environment variable. The -p option says that the command should create any parent directory that does not exist yet. For example, suppose that there's no directory called /a, then the command mkdir -p /a/b/c would create three directories: /a, then /a/b inside it, and finally /a/b/c inside it.
Regarding your second point: the first command will not return any output, it just defines the environment variable, so it's normal not to get any output. Similarly, the second command creates a directory and it does not give any output if it is successful. If the directory already exists, it does nothing at all.
I hope this helps!
Hi, I have just start on the book and I dont know much about the command on terminal for macbook. Do you recommend any resource to learn those command line ? Thank you
Most helpful comment
Hi @SM-Fahim ,
Thanks for your questions!
The first
$sign on each line is just there to indicate that the rest of the line is a command that should be typed in a shell (i.e., a Terminal window running a shell program such as Bourne Again Shell = bash, or zsh). Do not type the first$on each line.The
exportkeyword is used in a shell to define an environment variable. In this case, we are defining theML_PATHenvironment variable to be equal to the value of theHOMEenvironment variable followed by/ml. TheHOMEenv variable is usually automatically defined by your system to be equal to the path to your home directory, which is typically/home/your_login. So typically the first line will result in defining the env variableML_PATHto be equal to/home/your_login/ml(or/Users/your_login/mlon MacOSX).The second line uses the
mkdircommand to create the directory whose name we just defined in theML_PATHenvironment variable. The-poption says that the command should create any parent directory that does not exist yet. For example, suppose that there's no directory called/a, then the commandmkdir -p /a/b/cwould create three directories:/a, then/a/binside it, and finally/a/b/cinside it.Regarding your second point: the first command will not return any output, it just defines the environment variable, so it's normal not to get any output. Similarly, the second command creates a directory and it does not give any output if it is successful. If the directory already exists, it does nothing at all.
I hope this helps!