Shell common system Variable resolution: $ $ The name of the current script $n the nth parameter of the current script, n=1,2,... 9$* all parameters of the current script (excluding the program itself) $# the number of arguments to the current script (excluding the program itself) $? When a command or program finishes executing, a general return of 0 indicates a successful execution. $UID Current user's id$pwd current directory $$ is the current process ID number of the script run logical operator Resolution:-F to determine if the file exists eg:if [-f filename]-d determine if the directory exists eg:if [-D dir]-e Q equals applies To: integer comparison equal-ne not equal to: integer comparison not equal-lt less than applied: integer comparison letter-gt greater than applied: integer comparison greate-le less than or equal to: integral type comparison-ge greater than or equal to application In: integer comparison-A both are established (and) logical Expressions –a logical Expressions-o single-sided (or) logical expressions –o Logical Expressions-Z-empty strings
1 See which Shell you are currently using
[Email protected] conf]# echo $BASH/bin/bash
2 script +x to debug, troubleshoot errors
[[email protected] sh]#/bin/bash-x variable.sh + hellovariable.sh: line 2:hello: Command not found + a=123+ echo ' Print variables equal I S 123 ' Print variables equal is 123
3-E \ n line break
Echo-e "Start scripts. \ n .... "
4-E \033[32m \033[0m Promise color [32m can be changed to 33/34/35/36 color]
Echo-e "\033[32m start scripts. \n....\033[0m "
5 Linux commands, System built-in variables
[Email protected] sh]# echo $PWD/data/sh[[email protected] sh]# pwd/data/sh
6 $? The state after the command or program has finished executing, typically returning 0 for successful execution
[[email protected] sh]# Pwd/data/sh[[email protected] sh]# echo $?0[[email protected] sh]# sbash:s: Command not found [[email protect ED] sh]# echo $? Indicates that the previous command failed to execute successfully 127
This article is from the "Drow blog" blog, please be sure to keep this source http://6874869.blog.51cto.com/6864869/1877940
Shell Scripting Exercises