Getting started in the discussion of the more complex topics, we take a look at how the fish to complete some common shell task: to redirect the standard input and standard output, you should <和>using operator respectively. 和>
If you want to redirect the standard error, you should use the ^ operator, see Figure 1. Use the ^ ^ the standard error to a file. Figure 1-^ operator to redirect standard error in command 3, rm-generated error messages are redirected to errors file. Order 4 displays the contents of this file. Fishshell redirected offers a variety of support, such as the descriptor into a stream and end descriptor. By the way, the color of the text and underscore not editing. Shell when you enter in the CLI highlighted text. Green indicates that the command name is valid; invalid command name in red. Underlining indicates that the specified file exists. (Discussed in detail later in the section of the shell's feedback). Use parentheses (()) run sub shell, shown in Figure 2. The text in parentheses is interpreted as a series of commands, the shell will be replaced by the result. 2. the use of parentheses run sub sell by creating fish function creates aliases (shortcuts). Function can contain one or more commands, the special variable $ argv will automatically expand into the command line passed parameters list. You can use functions command lists all the functions have been defined. Use the delete function, for example functions--erasename functions--erasell. You can also immediately saved in the command line on any function. When you finish writing the code, for example, enter funcsavename funcsavell. After that, all currently running shell and all future shell you can use this function. You can use funcedname command interactively edit an existing function. Funced command provides syntax highlighting and tab-completion and auto indent; funcsave and funced enables users to more easily customize the shell. Enter setvariablenamevalue to set variables. Just as the built-in command functions, enter set--erasevariablename can remove a variable. Enter a dollar sign ($) and the name of the variable, you can obtain the value stored in a variable, see Figure 3. 3. check if a variable exists to provide fish--query option to check whether a variable is defined. If you have already set this variable, the return status code set--query 0, which indicates that no errors occurred; otherwise, it returns 1. Statement 6 used or operator joins two commands: the second command (echo) only in the first command fails to execute. So, how to handle fish $ var, ' $ var ', "$ var" and would $ var would? it observe a few simple rules: If the variable contains a space, the space will be preserved, variables are always as a single argument, see Figure 4. Figure 4.fish as is reserved string embedded spaces if the outermost quotes is the double quotation marks, then expand all of the variables. If the outermost quotes are single quotation marks, then do not expand variables. We take a look at the practical application of these rules. Command 1 creates four files, the last file name contain spaces. Command 3 and 4 to delete file variable to the specified file. Order 6 and 7 delete twofiles variable specifies the two files. Look at command 6: because the value is not in quotes (single or double quotation marks), so do not preserve white space. Therefore, the order of the variables expand 7 into two parameters and delete the two files. Order 9 and 10 repeat command 6 and 7 in the scene. Order 11 and 12 of the rules of your spaces. Although the command in a variable not put 12 in double quotation marks, but the fish in order to have spaces in November. Very good. Order 14 to 16 demonstrates nested quotes rules fish. Now, look at the order 11, 15 and 16. Shell uses color coding to display matching quote in order to ensure that the syntax is correct. Then look at command 9 and 11. After a command in the file name appears underlined on, which indicates that the file exists. There is no command 9 underline, it prompts the user to an error in some places. The first letter of the representative of the fish Friendly, user friendly is it's main goal.
No comments:
Post a Comment