Linux systems in order to facilitate operation and maintenance personnel to operate the system, so a lot of built-in shell command. In general linux system built-in command executes shell commands execute faster than external. Since the implementation of built-in command function is equivalent to calling the current process inside the shell, and execute external commands, then IO operations also need to start a separate process fork are performed after the completion of exit. The following lists some commonly used built-in commands linux system.
1、type
Mainly used to determine the current command is a built-in command or external command.
For example: type cd
Output: cd is Shell builtin
For example: type ifconfig
输出:ifconfig is /sbin/ifconfig
2, the implementation of the program:. ""
For executing a script, you can do not have permission to execute a shell script. This can go run the shell script without permission to modify the shell script.
3、source
This command can read and execute scripts in the current environment, and can return to the state of execution, execution success if no return value returns 0, indicating successful execution. If the specified script is found false.
4、cd
Change the current working directory. If you do not add any parameters, the default will enter the current user's home directory.
5, declare variables: declare, typeset
Both commands mainly to declare variables. declare variables necessary to specify the type of shell, are weakly type. However, if using the declare command, you can use the -i parameter declarations integer variable.
Instructions: declare -i num = 2 # declare declare statement is an integer variable num2, a value of 2
declare -r num = 100 # declare statement is declared read-only variable num, a value of 100
6、echo
Mainly used for printing characters, typical usage is to use the echo command and keep using content from the double quotation marks, the command will print the contents of quotation marks, the default will add a line break. -N can add parameters can not print a newline.
If you need to print the escape character, can be treated with the -e option, the default -e argument is not explicit.
7, integer arithmetic: let
let command is an integer computation command shell built.
Usage as follows: let num = 3 + 7 # num 10
let num2 = 15/3 #num 5
let num3 = 7/3 # 1 remainder num3
let num4 = 3 * 3 # 2 to the power of 2, num4 value 8
let num5 ++ # increment
let num6-- # decremented
let num7 + = 10 # num7 plus 10
8、pwd
Print the absolute pathname of the working directory.
Parameters :-P: print out the path name does not appear symbolic links.
-L: printed may comprise symbolic link path.
9、local
Declare a local variable, the typical usage is for in vivo function, the variable scope also function in vivo.
10.read
Mainly to increase the interaction between the user and shell scripts, it is simply the need to manually enter in order to continue execution of the script.
For example, look at the script:
#!/bin/bash
declare score
echo -n "Please enter your achievement:"
read score
echo "Your score is: $ socre points"
skill:
The following two can be modified
echo -n "Please enter your achievement:"
read score
Sentence:
read -p echo -n "Please enter your achievement:" score
11、return
A return value of the function. Usage is relatively simple.
12、test
For the value of the test expression returns 0 fails the test results, a success. Very important shell commands.
Syntax: test EXPRESSION
Reproduced in: https: //www.jianshu.com/p/422b91394357