A new version of Bash supports one-dimensional arrays. Array elements can be initialized using the notation variable[xx]. Alternatively, the script can use the DECLARE-A variable statement to specify an array, and so on. To refer to an array element
#查找当前目录中是否存在指定目录, if it does not exist, it is created
Copy Code code as follows:
function mkdir_1
{
if test! -D $
Then
mkdir $
Fi
}
#指定文件中的 "prefix =. *" string replaced with "prefix=/home/gnome-unicore-install2/usr/
To compare two strings for equality:
If ["$test" x = "Test" x]; Then
Here are a few key points:
1 using a single equal sign
2 Notice that there is a space on each side of the equal sign: This is what the Unix shell requires
3 Notice the last X of "$
Requirements: Delete files, directory structure: ip/year/month, everyone has a copy of this directory now need to delete all files before 2012, 2012 after the deletion of a specific month.Originally wanted to use find, the results found that these
The Ubuntu default does not have SSH service installed, which can be done with the following command:
Copy Code code as follows:
yblin@yblin-desktop:~$ ssh localhost
Ssh:connect to host localhost Port 22:connection refused
The shell script reads data in several ways:1. keyboard input, default2. read from the file3. Pass through Pipeline command
Functions of Echo:\c: No Line change\f: Paper Feed\ t: the jump Grid\ n: Wrapping Line\ represents escape, for example:
The bash shell supports only one-dimensional arrays, but there are no restrictions on the number of arguments.Declare an array:Declare-a Array(In fact, you don't have to declare that you can assign a value directly to a variable in an array, and
Today read a script file when there are some places do not understand, find an article to read some, feel good, keep down.Let's say we've defined a variable as:
Copy Code code as follows:
File=/dir1/dir2/dir3/my.file.txt
You
Randomly generated 10 8-bit password shell scripts1. First Capital Letter2. Middle six-digit alphanumeric random mixing3. Eighth place [0-9]
#!/bin.bash for
i in {1..10}
do
a= ' head-c 500/dev/urandom | tr-dc a-za-z | tr [A-z] [a-z]|head-c 1
The script that prints the Java thread occupancy stack is invoked if the CPU occupancy rate continues to reach more than 80, see https://github.com/oldratlee/useful-shells/blob/master/ Show-busy-java-threads.sh, see his GitHub wiki! in concrete
Many times, we will write a shell program to complete some of the time without duplicating the wheel, but because the shell statement will also have functions, there will be variables, in the end after the implementation of what related operations,
Thread classification
Threads can be divided into user-level threads and core-level threads according to their dispatchers.
(1) user-level threadsThe user-level thread mainly solves the problem of context switching, and its scheduling algorithm
One, logical operators
Logical Volume Label
Express meaning
1.
About the files and directories of the detection of logical labels!
-F
Common! Detect the existence of "archives" eg:if [-f filename]
First, the method
Copy Code code as follows:
/**
* Execute a shell command and return the string value
*
* @param cmd
* An array of command names & parameters (for example: {"/system/bin/cat", "/proc/version"})
* @param workdirectory
Script 1: Write a login welcome script for root users:
1, with vi command in the/root directory is a new script file welcome.sh, the contents are as follows:
2, using the chmod command to welcome.sh file to increase the execution (x) permissions
Set font and background color under BASH shell\e[30m change the display color of a character to black\e[31m change the display color of a character to red\e[32m change the display color of a character to green\e[33m change the display color of a
Security code: Taohuatan depth thousand feet, less than mountain send Me love.File descriptor (FD): The file descriptor is a non-negative integer, and when you open an existing file or create a new file, the kernel returns aFile descriptors, and
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