[Condition 1-a Condition 2] When 1 and 2 are true [condition 1-o condition 2] when 1 and 2 one is true [! condition] Take counter && and | | Or! unsigned [-D name] && Echo ' is dir ' is true when the name is directory, then the input has the
The program must start with the following line (must be in the first line of the file):
#!/bin/shThe symbol #! is used to tell the system that the parameter behind it is the program used to execute the file. In this example we use/BIN/SH to
Shell script (i)1. Common Commands(1) System Management#useradd, a user group with the same user name is created by default when a new user is added#创建用户user1 and specify a UID of 1111, the owning group is 2222 (test), and the home directory is not
If you want to add a character after a variable, you can use the following method: $value 1=home$value2=${value1}"="Echo$value 2 Add the string variable you want to add {}, and you need to put the $ out. The result of this output is: Home=, which
In the shell, especially in the shell loop, some expressions may be used to operateThis requirement can be accomplished using the expr command, such as:x=$ (expr $a + 1)Completed the calculation of the sum of $ A and 1 and assigned the value to
Linux Shell Program DebuggingThe shell program is debugged by adding relevant debugging options when running the program or by adding related statements to the script, allowing the shell program to display some "debug information" for reference
$ who can know how many landings on the system$who |wc-l count the number of usersNote: | is a pipe symbol that can be used to establish a pipeline between two programs (pipeline): The WHO output, a WC input, the result of the WC is the number of
Find DocumentsIt is quite convenient to find text in the grep program (matching text matching). There are traditionally three programs that can be used to find entire text files.
grep's oldest text-matching program. The simplest way is to
The shell is an interpretive programming language.The execution of an interpreted script file:When an interpreted script file is executed, the script file is committed to the kernel. The kernel sees the first line of "#! "#! is called when the
For some reason, Xcode has helped me follow the thousands of development and on-line certificates that need to be removed from this part of the certificate: #dir="/users/ethan/library/mobiledevice/provisioning
Method Two/sbin/ifconfig-a|grep inet|grep-v 127.0.0.1|grep-v Inet6|awk ' {print $} ' |tr-d ' addr: 'Method OneGet the native IP address and save it in a variablearg=ifconfig eth0 |grep "inet addr"| cut -f 2 -d ":"|cut -f 1 -d " " Ipaddr=
a
1.12 Functions and Parameters
Like other scripting languages, Bash also supports functions and can pass parameters.
1.12.1 function definition and parameter transfer#!/bin/bash function fname () #也可以用fname () instead of {echo $1 , $
ShellThe shell is a weakly typed programming language.Distinction between strong and weak:Strong: Variables must be declared prior to use, and even require initialWeak: Variables are declared when they are used, even the part is differentiated by
1.8 using Aliases
aliases in Linux are the equivalent of shortcuts in Windows, and using aliases can save users from having to enter a long sequence of commands.
1.8.1 Creating temporary aliases (shortcuts)alias new_command=‘command
Defining arraysArr= (1 2 3 4 5)accessing arrays# echo ${arr[0]}1Print all the values in an array# echo ${arr[*]}1 2 3) 4 5Print array length# echo ${#arr [*]}5The above defined array, the index can only be a number, the following will describe the
In Linux, the shell variable $ #, $ @, $0, $1, $2 has the following meanings :,
Variable description:
$ PID (ProcessID) of Shell itself $! PID of the background Process last run by Shell $? End code of the last command (Return Value) $-Flag list
Shell script to delete the folder N days ago ----- the difference between the date command on linux and mac
Background:Every day you build things and put them in different folders by date. For example, today's construction is put in, tomorrow's will
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service