If the expression contains special characters, the Shell will replace it. For example, using a variable in double quotes is a substitution, and an escape character is also a substitution.As an example:
#!/bin/bash
A=ten
echo- e "Value of A is $a \ n"
Operation Result:Value of A is 10Here-e indicates the substitution of the escape ch
If the expression contains special characters, the Shell will replace it. For example, using a variable in double quotes is a substitution, and an escape character is also a substitution.As an example:
#!/bin/bash
a = Ten
Echo-e "Value of A is $a \ n"
Operation Result:Value of A is 10here-e indicates the substitution of the escape character.
If the expression contains special characters, the Shell will replace it. For example, using a variable in double quotes is a substitution, and an escape character is also a substitution.As an example:
#!/bin/bash
A=ten
echo- e "Value of A is $a \ n"
Operation Result:Value of A is 10Here-e indicates the substitution of the escape ch
Command substitutionCommand substitution means that the shell can execute commands first, save the output temporarily, and output it where appropriate.Syntax for command substitution:' Command 'Note that it is an anti-quote , not a single quote, which is below the ESC key .In the following example, the command execution results are saved in a variable: #!/bin/bas
that matches the keyword
${variable/old string/new string}
Replace the first old string with a new string if the contents of the variable conform to the old string
${variable//old string//new String}
Replace the first old string with a new string if the contents of the variable co
If the expression contains special characters, the Shell will replace it. For example, using a variable in double quotes is a substitution, and an escape character is also a substitution.As an example:
#!/bin/bash
A=ten
echo- e "Value of A is $a \ n"
Operation Result:Value of A is 10Here-e indicates the substitution of the escape ch
Replace: If the expression contains special characters, the shell will replace it. For example, using a variable in double quotes is a substitution. The escape character is also a replacement#! /bin/Basha=tenecho"Value of A is ${a} \ n"The #-e indicates that the escape character is replaced with no output as follows #echo "Value of A is ${a} \ n"Escape character SubstitutionThe following escape characters a
1 . Deletion and substitution of variable contents# The representation is deleted from the front, so here it starts / deletes ,* instead of 0 to infinitely more than any character% Delete variable contents from behindFor example:echo ${path%:* bin} deletes the most a directory, that is, the string from: to the bin and is the shortestEcho ${path/sbin/sbin}: two sl
variable Name
Reads a string from the standard input and passes it to the specified variable
Shift
Offsets the position of the variable, that is, the $1,$3 becomes the $ $, each time it executes $#-1
1. Eval:
An eval can only allow the shell to process parameters one more time, so there are several more eval can be added several ti
complex expression, you need to write the expression branch:
printf (%s is%d years old.
Template
, "Fred", 35);
Single and double quotes in Heredoc are skipped (as a general symbol):
$dialogue = "It ' s not going to happen!" she fumed.
He raised an eyebrow. "Want to bet?"
No_more;
Echo $dialogue;
"It ' s not going to happen!" she fumed.
He raised an eyebrow. "Want to bet?"
Whitespace characters in Heredoc are also preserved:
$ws = Boo
Hoo
enough;
$ws = "boo\n hoo\n";
Because the
ImportReif __name__=="__main__": URL="\ deded""> This is the first link ""> This is a second link " #remove \ none = Url.replace ("\ n","") #Remove both spacesboth =One.strip ()#The regular match Re.match matches from the beginning of the string. three = Re.match (r"(", both)ifThree is notNone:arr=three.groups ()Print(Arr[0] +"hahaha"+ arr[3]) #The regular lookup contains result = Re.search ("", both). Group ()Print(Result)#regular Find and replace Print(Re.sub (Re.compile (R"", Re.
1. DEFINE substitution variable 1. Set the exact value definemyv through DEFINE
1. DEFINE substitution variable 1. Set the exact value define myv = through DEFINE
I. Define substitution Variables
1. Set the exact value through DEFINE
Define myv = 'King ';
The value of t
", echo "$test" x y z #引用变量值, and leave the space in the variable > Note: The value of a variable can be part of a long string. If it is at the end of a long string, it can be referenced directly, and if it is at the beginning or the middle, enclose the variable in curly braces. Example: [[[emailprotected] tmp]# test= "xyz"; Echo
[subscript]: Start: Number of characters)ExampleServer= (www.baidu.com www.163.com)echo $ (#server [@])echo $ (#server [1])Wall "error" sends a warning message to all terminals, with a warning message in double quotesShell variable substitution (changing the way variables are assigned)$ (Variable name variable
1 SED supports the substitution of variables in two ways, it is recommended to use the following second, relatively simpleThis allows the variable A to be assigned a number of special characters, such as Assignment a= '! @#¥% ... 'Sed-n ' s/echo/' "$a" '/P ' AASed-n "s/echo/$a/P" AA2 Linux special characters Daquan, see links
Shell Escape character
Character
Description
initial value can be determined at compile time, the final variable is essentially a "macro variable", and the compiler replaces all of the program's values with that variable directly.
On the surface, the 1-line code defines a book2 that is not much different from the book, but explicitly converts the value 99.0 to a string when the BOOK2
? One way to put it online is to replace the characters in the SED that represent the substitution with the characters that are not in the other variable so that it is equivalent to the characters in the variable that are not escaped. Such as:Sed–i "s# $Comfilename #/root/#" filename.listThis is a good idea. But unfortunately what I need is to delete "D" instead
Tags: Oracle contract insert RAC EFI INI method ack imagesI. Description of the problem The following sql: INSERT into TMP (val)VALUES('ab'); View Code The following prompts will appear during execution: After clicking "OK", we look at the data in the table: The string after B is not inserted. Two. Reason Analysis-substitution variables The default "" in Sql*plus represents an alternative variable, and w
Transferred from: http://www.blogjava.net/pingpang/archive/2012/08/12/385342.html1. JavaScript regular object substitution creation and usage:/pattern/flags A simple case study to understand what replace can do:Regular expression constructors: New RegExp ("pattern" [, "flags"]);Regular expression substitution variable function: stringobj.replace (regexp,replace T
empty.Conclusion: When CMZ has no content, it returns to unset.[Email protected] ~]# cmz= "Caimengzhi"[Email protected] ~]# Result=${cmz:-unset} #之前必须声明cmz变量[Email protected] ~]# echo $resultCaimengzhiConclusion: When CMZ has content, it returns the contents of CMZ variables.This variable function solves the work string problem, and the variable is undefined.2, ${value:=word}[[email protected] ~]# Result=$
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.