Description : This is a relatively simple bash script editor, but has been tested. The reason for writing this blog is to practice the loop control language, functions, positional parameters, local variables, and function parameter calls, as well as calls between functions, as well as parameters for obtaining user options and options.Note: The script options and the script options parameter get method use getopt and make further judgments, consult the
Wildcard characters in Bash (wildcard)*: Any character of any length.?: any single character []: Match range [^]: Exclude Match range [: alnum:] [: Alpha:] [: Blank:] [: cntrl:][:d Igit:] [: Graph:] [: Lower:] [:p rint:][ :p UNCT:] [: Space:] [: Upper:] [: xdigit:]Regular expressions.: Indicates matching any single character. *: Indicates that matches the preceding character any time, including 0 times. *: represents any character that matches any len
Learning bash notes-debugging shell programs and learning bash shell
In shell, the simplest debugging assistant outputs the echo statement. Many echo statements can be put into the code for debugging, but it takes enough time to locate
The information to view. You may need to output a lot to find the information you want to search.1. the most basic set-o Command Options are set-o Command Options. These opti
Location parameters$0, $1, $2, etc. .. (note that when the number of parameters is greater than 9, you should reference $ {10}, ${11 }...)Location parameter, which is passed to the script from the command line, to the function, or to a variable.Example:
#! /Bin/bash
#./Test. Sh first second third
Output:
First parameter first
$0 =./test. Sh
When the number of parameters is greater than 9:
#! /Bin/bash
#./
pre-Class review : To find the sum of divisible by 3 divisible by 200# !/bin/bash -Isum= 0 for with {1..200};d o if [$[$i%3]-eq 0]; then let Su M+="Thesum is: $sum"Bash's knowledge points :Conditional testing: Making a logical operation on a condition with : Condition 1 Condition 2 or : Condition 1 | | condition 2 non- :! Conditions example :#userName =root#id $userName echo "userName exist"If the former fails,
Description : This is a relatively simple bash script editor, but has been tested. The reason for writing this blog is to practice the loop control language, functions, positional parameters, local variables, and function parameter calls, as well as calls between functions, as well as parameters for obtaining user options and options.Note: The script options and the script options parameter get method use getopt and make further judgments, consult the
Bash script skills-trap Command, bash script-trap
Share a shell script technique. When you write a shell script, you generally only ensure that the function is available, but the program is not very robust and not robust enough. Most of them are script processing.
The built-in trap command can handle unexpected system signals, for example:
Trap "rm-f/var/lock/subsys/my_program_lock_file; Exit 0 "1 2 9 15
Set bash options with built-in set and SHOPT commandsThe set command can be used to customize the shell environment, using the option "O" to turn options on or off. For example, open the options: Set-o option, close the Select item: Set +O option.For example, to open the VI Interactive command-line edit, the following:
[Email protected] ~]#Set-o#查看当前设置情况Allexport offBraceexpand onEmacs onErrexit offErrtrace offFunctrace offHashall onHiste
************************************************************************* * * * Original:blog.csdn.net/clark_xu Xu Changliang's Column************************************************************************? time to read the file#!/bin/bashFor file in ' Ls/root 'DoStat $file >1.txtSed-n "7p" 1.txt>2.txtUsetime= awk-f ":" ' {print $2.txt} 'echo "Time=" $file $usetimeDone? reads each line of the file while statement. Cat Afile | While Read onelineDoEcho $onelineDone? reads each line of the file
In Windows 3.02 64-bit system, when cygwin is used to run the liunux program, the following error occurs: Bash-$:
The reason is:
In the 64-bit operating system, the 32 program and the 64-bit program read the location registry key, in the 64-bit Registry Editor, HKEY_LOCAL_MACHINE \ SOFTWARE corresponds to the registry key of the 64-bit program, and the 32-bit registry key is mapped to HKEY_LOCAL_MACHINE \ SOFTWARE \ wow6432node. If both versions are r
Bash array, bashBash only supports one-dimensional arrays. And the array subscript starts from 0.Assign values to Arrays:Array = (1 4 7 2 5 8) # use space as the delimiter and () as the arrayStr = "this is test string"Str_arr = ($ str); # separated by spaces by defaultArray traversal:For val in str_arr [*]; do echo $ val; doneFor file in 'LS'; do echo $ file; doneNumber of array elements: $ {# array}For example, each character in a string is split int
$filename/etc/sysconfig/network-scripts[[email protected] Network-scripts] #将第一次出现的小写s替换成大写的S [[email protected] network-scripts]# echo ${filename/s/s}/etc/sysconfig/ Network-scripts[[email protected] network-scripts] #将所有的小写s替换成大写的S [[email protected] network-scripts]# echo ${ Filename//s/s}/etc/sysconfig/network-scripts[[email protected] network-scripts]# Summary:/match/ Value: Replace the first occurrence of match with Value//match/value: Replaces all match with value
Operators for
In everyday English, the shell can be translated into shells, most of which means a device or structure that can protect the inner core. In computer science, the shell actually refers to a provider that can use the entire computer's resources through system calls or library calls.It is both a command parser and a programming language. As a command parser, it can interpret and execute user-entered commands, and can automatically interpret and execute a
Recently there has been a "destructive level" vulnerability--bash software security vulnerabilities. The loophole was discovered by French gnu/linux enthusiasts Stéphane Chazelas. Subsequently, the United States Computer Emergency Response Center (us-cert), Red Hat and a number of companies engaged in safety in Wednesday (Beijing time September 24) issued a warning. Details of this vulnerability are availab
In everyday English, the shell can be translated into shells, most of which means a device or structure that can protect the inner core. In computer science, the shell actually refers to a provider that can use the entire computer's resources through system calls or library calls.It is both a command parser and a programming language. As a command parser, it can interpret and execute user-entered commands, and can automatically interpret and execute a
following table:
The corresponding operation integer operation string operation
Same-eq =
Different-ne!=
Greater than-GT >
Less than-lt Greater than or equal to-ge
Less than or equal to-le
Is null-Z
Not null-n
Like what:
Compare integers A and b for equality and write if [$a = $b]
To determine if an integer A is greater than integer b, write if [$a-gt $b]
Compare strings A and b for equality on writing: if [$a = $b]
To determine if a string A is empty, write: if [-Z $a]
To judge whether an int
executed. When user_compile () is executed,/etc/ebuild. conf has been executed, and "$ makeopts" has been set to the correct value.
ConclusionThis article has already talked about many bash programming techniques, but it only involves some of the capabilities of bash. For example, Gentoo Linux ebuild not only automatically unpacks and compiles each package, but also:
If no source code is found in "$ DIS
Bash remote parsing command execution vulnerability Test Method
Since yesterday, the BASH remote command execution vulnerability from a vast ocean of Australia has boiling the entire FreeBuf. Everyone is talking about it, "The Heart of the Internet is bleeding again, how can I test my website? The following script
$ env x=‘() { :;}; echo vulnerable' bash -c "ec
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.