shell(shell) is a command line interface (CLI) program that can receive commands entered by the keyboard and pass them to the operating system for execution. Today, in addition to the command-line interface (such as shell), we also have a graphical user interface (GUI).
On most Linux systems,BashIs the default shell program.
On older Windows systems,CMD.EXEIs the default shell program. In the latest version of windows 10 system,PowerShellIt has become its default shell program, but cmd.exe remains in it.
Terminal emulator can be referred to as terminal in most cases. It is a window program that allows you to interact with the shell. Developed and open source by MicrosoftWindows TerminalIs one of them.
Basic syntax of commands
Taking PowerShell as an example, this paper discusses the basic syntax format of calling shell commands.
In PowerShell, type after the command
-?Parameter and enter, you will get the basic usage of this command. For example, we enter
copy -?When, you will get the following prompt:
PS C:\Users\hookin> copy -? name Copy-Item grammar Copy-Item [-Path] <string> [[-Destination] <string>] [<Com monParameters>] Copy-Item [[-Destination] <string>] [<CommonParameters>] alias cpi cp copy remarks Get help could not find the help file for the cmdlet on this computer. It shows only part help. --To download and install the help file for the module that contains this cmdlet, use the U pdate-Help。 --To view the help topic for this cmdlet online, type: "get help" Py item - online "or Go to https://go.microsoft.com/fwlink/?LinkID=113292 。
go tohttps://go.microsoft.com/fwli…View online help.
You can see the full name of this command
Copy-Item, we used its alias
<xxx>The meaning is as follows:
Optional parameters, which can be omitted and not written,
-xxxIs a parameter, with left and right square brackets
]Package indicates optional, for example:
copy *.txt child copy -Path *.txt -Destination child
The effect of executing these two commands is the same.
If explicitly declared
-PathOr / and
-DestinationParameter, the position of the explicitly declared parameter can be changed:
copy -Destination child -Path *.txt copy -Destination child *.txt copy child -Path *.txt
PowerShell will recognize the position of the value and determine which parameter it corresponds to (how to judge will be described below).
Required value, such as
-PathThe parameter is writable or not, but the value after it
string(represents a string array, which will be described below) must be written.
-DestinationAnd its value
stringThe composition of the whole is optional, but if you want to use this parameter, you can write it directly
PowerShell supports many data types, including
SwitchParameterWait, you can read the online help when you encounter it.
String type. Double quotation marks can be omitted without writing.
copy -Path *.txt -Destination child
String array. The above code can be written as follows:
copy -Path 1.txt,2.txt -Destination child
That is, the elements in the array are separated by commas
Switch parameters, equivalent to
BooleanBoolean, when typed
true, default when not typed.
PS E:\Temp\dosTest> copy -Path 1.txt,2.txt -Destination child -Confirm confirm Are you sure you want to perform this operation? Performing action copy file on target item: e: \ temp \ dostest \ 1.txt target: e: \ temp \ dostest \ child \ 1.txt. [Y] Yes [a] Yes to all [n] no [l] no to all [S] pause (s) [?] help (default is "Y"): y confirm Are you sure you want to perform this operation? Performing action copy file on target item: e: \ temp \ dostest \ 2.txt target: e: \ temp \ dostest \ child \ 2.txt. [Y] Yes [a] Yes to all [n] no [l] no to all [S] pause (s) [?] help (default is "Y"): y
In the above command, you typed a command that is not given in the local help
-ConfirmParameters, according toCopy item online helpDescription of:
Prompts you for confirmation before running the cmdlet.
Prompt you for confirmation before running the cmdlet.
attribute value Type: Switchparameter switch parameter Aliases: CF, i.e
Position: Named requires active declaration Default value: False error Accept pipeline input: False error
You can see that its default value is
true, but you can also take the initiative to declare
copy -Path 1.txt,2.txt -Destination child -Confirm:$false copy -Path 1.txt,2.txt -Destination child -Confirm:$true
Let’s have a look
copyIntroduction to several parameters of:
Specifies, as a string array, the path to the items to copy. Wildcard characters are permitted.
Specifies the path of the item to copy as a string array. Wildcards are allowed.
attribute value Type: String Position: 0 Default value: None Accept pipeline input: True Accept wildcard characters: True
Specifies the path to the new location. The default is the current directory.
Specifies the path to the new location, which defaults to the working directory.
To rename the item being copied, specify a new name in the value of the Destination parameter.
To rename the item being copied, specify a new name in the value of the destination parameter.
attribute value Type: String Position: 1 Default value: Current directory Accept pipeline input: True Accept wildcard characters: False
Compare these parameters:
-ConfirmThe position of is
Named, indicating that its value can only be modified after declaration; The position value of other parameters is
1, indicating the order of reading.
PowerShell is pre configured
PositionTo determine which optional parameter the parameter value corresponds to.
copy -Destination child *.txt #*. TXT is the value of - path copy child -Path *.txt #Child is the value of - destination copy *.txt child #*. TXT is the value of - path，child 是 -Destination 的值 copy -Path 1.txt,2.txt -Destination child #- confirm is the default value false copy -Path 1.txt,2.txt -Destination child -Confirm #- confirm is true