NOTES: # Note: The # in #!/bin/bash at the beginning of the shell file is not a comment run: 1, bash shell.sh 2, chmod +x shell.sh./shell.sh 3, add to Path change Amount of 4,. ./shell.sh Troubleshooting: 1, syntax error when running with prompt 2, logic error using echo printing, Sleep Number: Sleeping number seconds, reduce the cycle speed using Bash-x To debug a shell script third-party tools: Bashdb built-in commands: 1, determine whether a command is built-in: Type 2, execute the program: ".", even if the file does not have execute permission, you can make it perform the example:. ./helloworld.sh equivalent to Source:source helloworld.sh 3, aliases: Alias A, #alias view current shell alias B, #alia s mycommand= ' command ' C, in order to save alias, you can add 4 to the. bashrc file in your home directory, remove aliases: Unalias 5, switch between front and back of task: Bg,fg,jobs 6, change directory: CD 7 , declaring variables: Arguments for DECLARE, typeset DECLARE commands:-I: Declaring a variable is an integer type-r: Declaring a variable to be read-only type-a: declaring an array -F/F: Displays the functions and functions defined in the script-x: Declares a variable as an environment variable for the script and is exported 8, Echo-n: Do not print newline characters-E: Disables the explanation of character examples for printing backslash escapes: echo "\ n" result is \ n echo-e "\ n" result is a blank line echo: NewLine 9, break when there is a numeric parameter number (must be greater than 1), it means jumping a few layers of the loop 10, continue when there is a numeric parameter number(Must be greater than 1), means jumping out of several layers of loop 11, Eval will follow the parameters as the shell input, and execute the resulting command 12, exec execute command to replace the current shell, the typical application is with find The built-in command exec does not start the new shell, but instead replaces the current shell process with the executed command, and cleans up the environment variables of the old process, and the other commands after the EXEC command are no longer executed. Example: A, list all the files in the system that end with. conf Find/-name "*.conf"-exec ls-l {} \; b, delete all temporary files in the system love you find/-name "*.tmp"-exec rm-f {} \; 13, exit Exit 14, make the variable can quilt Shell to identify export 15, kill send signal to the specified PID or process Linux three processes: Shell interaction process, batch process, system The system daemon process. Kill Process 16, integer operation Let's example: let i=2+2 let j=5-4 let K=2*5 let L=17/5 Let m=15%7 let n=2**4-->n=2^4=16 let i++ let j--let i+=10 l Et j-=10 17, displaying the current working directory PWD 18, declaring local variables locally 19, reading one line from a standard input to a variable: Read 20, return 21, SHIFT, move position parameter position parameters to the left: $ ... $N: Indicates the nth argument [email protected] or $*: All arguments are represented by a: the script itself $#: representsTotal number of parameters 22, display and set process resource limits Ulimit 23, test
One of the Shell learning notes (shell built-in command)