LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help needed to understand command line syntax. (https://www.linuxquestions.org/questions/linux-newbie-8/help-needed-to-understand-command-line-syntax-4175712032/)

complete 05-13-2022 03:18 AM

Help needed to understand command line syntax.
 
I confess, I have been using GUI interfaces for a few decades. I have gotten used to Microsoft Windows Operating Systems and I have not spend enough time navagating all of the command line commands.... and this is especially true for Linux distributions like Ubuntu.

I DO know what 'cd ..' does when I type it on a Ubuntu command line as well as 'ls'. And I know where '../Directory' will take me. It goes up one level in the folder structure and then back down to where ever the 'Director' folder is. So, if the folder I am currently is is called 'RightHere', then the command line entry of '../RightHere' will seemingly take me no where.

But I never learned what a single dot means. For example, where is the folder 'interest' in the command 'gzip -d ./interest/dino-mod.tar.gz'.

Also, I do not know how '&&' is used. What would the following line do:

'cd ../engine && mkdir thirdparty'

It looks like two commands. So why are they on one line? Is it to make them execute at the same time? Is one command dependent on the other? Where would the directory 'thirdparty" be made?

All of these are examples of what (sort of) appears in a .sh file I need to execute. I need to know these details to ensure that the directory paths align and are accurate to where I will execute the .sh file.

pan64 05-13-2022 03:27 AM

. means (in this context) current directory. see: https://en.wikipedia.org/wiki/Path_(computing) (look for relative path).
&& means "and", so cd ../engine && mkdir thirdparty means change dir into ../engine and make directory named thirdparty if that first command (cd) was successfully executed.
https://stackoverflow.com/questions/...-shell-command

evo2 05-13-2022 03:32 AM

Quote:

Originally Posted by complete (Post 6352807)

But I never learned what a single dot means. For example, where is the folder 'interest' in the command 'gzip -d ./interest/dino-mod.tar.gz'.

That means the current directory.
Quote:

Originally Posted by complete (Post 6352807)
Also, I do not know how '&&' is used. What would the following line do:

'cd ../engine && mkdir thirdparty'

It looks like two commands. So why are they on one line? Is it to make them execute at the same time? Is one command dependent on the other? Where would the directory 'thirdparty" be made?

It is a logical "AND". It is kind of a trick to use it this way. When performing a logical "A AND B", if A is False, there is no attempt to evaluate B.

So, if the first command, "cd ../engine", completes without an error return code (return status is 0) then the second command, "mkdir thirdparty", will be run.
Quote:

Originally Posted by complete (Post 6352807)
Where would the directory 'thirdparty" be made?

It would be "../engine/thirdparty".

HTH,

Evo2.


All times are GMT -5. The time now is 08:02 PM.