The original book This example is to teach debugging script, it deliberately gave a few errors in the script, teach us to understand the system prompts the error, and modify the run. But it's more difficult to write, so put the modified script up,
Conditional judgment: If statement
Syntax format:
If [expression]
then
Statement (s) to was executed if expression is true
fi
Note: There must be a space between the expression and the square brackets ([]), otherwise there will be a
It is common to repeat a series of commands while running a script, when we need to use a loop statement to do this.
One, for command
Format: for variable in list;
Circulation body
Done
The for command traverses each value in the list and exits
Objectivetoday I just wrote an automated packaging script, again using the bash shell, a good feeling of happiness. The main point here is to introduce the Select command, which can help us complete the menu selection function.
FormatI am also the
1 Ensure that you are in the home directory (if not, run: cd/home)2 New Backup folder (command: mkdir backup)3) New Script backup.shVI backup.sh
Copy the following code (after replication: wq! to save):
Copy Code code as follows:
#!/bin/
Provides an operational expression in the following format: $ ((expression))
$ echo $ ((5* (3+3))
30
$ result = $ (($myvar-10))
The shell provides a convenient number of conversions between:
$ echo $ ((013)) #八进制
$ echo $ ((0xa4)) #十六进制
You can
1, backup_run.sh
Copy Code code as follows:
#!/bin/sh
# Backup_run
# script to run the backups
# loads in a setting file for the ' user to ' change
Source=/home/bob/backup.defaults
Check_source ()
{
# Check_source
# Can we load
When we are testing or commissioning, sometimes you need to generate a file of size, for example, when testing the storage system, you need to reduce the amount of disk space 5G, the easiest way is to copy a 5G file over, but where to get the size
Nothing recently, I wrote a code statistics gadget based on SVN in bash. You can specify a catalog of statistics, and the default recursive statistics subdirectory.
Currently, there is no capability to mask the specified directory. The code is
In the Linux system for day-to-day operations or scripting, variables are more familiar with, but what are the types of variables, what is the difference in the specific usage? This paper is to share with you:
One, bash variable type:
Local
There are several ways to execute a shell script
1, relative path mode, need to first CD to script path
Copy Code code as follows:
[Root@banking tmp]# Cd/tmp
[Root@banking tmp]#./ceshi.sh
Script execution succeeded
2.
Method 1: Add a variable to an integer value by using expr, or an integer if it is performed correctly, or an error is executed, $? will be a value that is non 0
Copy Code code as follows:
Expr $args + 0 &>/dev/null
Method 2
The previous script is in save mode, now attach the command to a file, so that it can be easily modified two times or somethingThe script is basically like this, we can change with their situation again ~ add function or something.
The generated password and user input can accept duplicate numbers.So the relative general rule of guessing numbers may be much more difficult.
This version of the rule:
a--numbers are right, position is right.b--excludes the result of a, the
Test the effect of prefetching, using the CPU to always view the effect. According to the experiment found that the prefetch address in the address before the use of the 10 lines around the code at the effect is better!
Copy Code code as
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
Today colleagues idle, asked me to help in the Linux login page to add something he thinks is very unique, look at his hair, said to him is very silent, below to see.
Script 1:
Cat clcal.sh
#!/bin/bash # show Chinese lunisolar calender. # 2011
A few days ago wrote seven bull demo, with Bash wrote a convenient installation of the script, involving the path-related judgments, from StackOverflow, plus their own practice to tidy up.
Simple version
The following is one of the simplest
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.