{print ' $oldboy '} '123[[email protected] ~]# awk ' BEGIN {print "' $oldboy '"} '123With awk, the opposite is the case, with single quotes, double + single resolution variables, and double quotes as output. Nothing adds output to null.Summary: If you want to output the same as the double quotation marks, the resolution variable with double + single (' xxx ')The old boy for convenience, generally not directly with awk, but using the method of the pipeline, first echo variable let the pipeline t
Shell Introduction
The shell is a programming language interpreter, which interprets commands entered from the keyboard, and also explains the sequence of commands stored in the script, which is a file containing a series of commands, and running a script is running each command in the file. You can use a shell sc
1th Shell Basics 1.1 What is a shell
The shell is a command interpreter, which at the outermost of the operating system, is responsible for directly talking to the user, explaining the user's input to the operating system, and processing the output of a wide variety of operating systems, returning the output screen to the user.1.1.1
Common shell programming tips-general Linux technology-Linux programming and kernel information. For more information, see the following. 1. system environment variables after the user logs on to the system:
$ HOME user's own directory
$ PATH: the directory to be searched during Command Execution
$ TZ Time Zone
$ MAILCHECK the number of seconds to check wh
I. Introduction to Linux Shell1. Shell overviewThe shell is an interface that the user interacts with the kernel, and the most popular shell is now called the Bash shellThe shell is a programming language The Shell is a scripting
generated file to $ Umask 000, which is changed to 000, and the specific rules refer to the table above.In fact, the value of Umask is set in/etc/profile this configuration file, for a specific user, you can set their own umask in $home/.profile or $home/.bash_profile1.7. Symbolic Link, LnHard links, $ ln resource destinationSoft links, $ ln-s resource destination1.8. Learn the yuanyin of shell scriptsShell scripting is powerful, for example, for a
Shell script Programming:Classification of programming languages: depending on how they are runCompile-and-run: Source code--compiler (compile)---Program files;Explanation Run: Source code-and run-time start interpreter, run by interpreter side explanation side;Depending on whether the implementation of the functionality in the programming process is calling the
Simply put, the shell is a file containing several lines of shell or Linux commands. For a large number of commands that are written and used more than once, you can use a separate file to save it for later use. Usually the shell script is suffixed with. SH, and the first line must indicate which shell the system needs
Shell script programming Selection Control Structure
There are two programming languages: interpreted language and compiled language. An interpreted language is an interpreted statement that can be executed on Demand Based on the process control mechanism. When a statement is interpreted, the result of the statement is returned. This language requires an interpre
First, declaring variablesMyurl= "http://see.xidian.edu.cn/cpp/linux/"mynum=100Attention:There can be no spaces between the variable name and the equals sign, which may be different from any programming language you are familiar with.At the same time, the name of the variable names must follow the following rules:The first character must be a letter (a-z,a-z).You can use an underscore (_) without spaces in the middle.Punctuation cannot be used.You can
-x//set -x表示跟在该命令后的脚本输出调试信息echo$i//set +x表示从此处禁用调试set +xdoneecho"Script executed"The above code means that only the output echo $i is printed, and the specific debug information output is as follows:[Email Protected]2:~/shelllearning/chapter12#./debug2.sh+Echo 11+Set+x+Echo 22+Set+x+Echo 33+Set+x+Echo 44+Set+x+Echo 55+Set+x+Echo 66+Set+xIn addition to script debugging with the Bash-x command, you can also add the-XV command to the first line of the script, allowing the script to debug by defaul
The shell supports custom variables.Defining variablesWhen defining a variable, the variable name does not have a dollar sign ($), such as:Value= "TMP"Note that there can be no spaces between the variable name and the equals sign, which may be different from any programming language you are familiar with. at the same time, the name of the variable names must follow the following rules:
The first ch
Shell Script BASIC Programming fourth articleMain contents of this chapter: functionsFunctionfunctionfunction name {command;} or name () {command;}Defines the Shell function.Create a shell function that is named name. When enabled as a simple command,The NAME function executes the COMMANDs command in the context of the
Linux Command Line and shell script Programming
This time, I read the Linux Command Line and shell script programming book for 3rd Times. In general, this book is quite good. It is suitable for beginners. I also learned about shell progr
The shell is an interface that users interact with the kernel, and the most popular shell is now called the Bash shell. The shell is also a programming language , Shell Scripting The original text is discussed with the author: htt
Shell basic syntax
Like an advanced programming language, Shell also provides instructions and the ability to use variables. For Shell, the values of all variables are a string. The Shell program uses $ var to reference the value of a variable named var.
$ match end of line
grep "^m" Test_rule.txt
Match lines that start with capital M
grep "n$" Test_rule.txt
Matches a line ending in lowercase n
Grep-n "^$" Test_rule.txt
Match Blank Line
4 [] matches any one of the characters specified in parentheses, matching only one character
grep "S[ao]id" Test_rule.txt
Match between S and I letters, either a, or O's line
grep "[0-9]" test_rule.txt
Match any one number
grep "^[a-z]" test_rule.txt
Match a line that starts with a lowerca
This section mainly discusses the mathematical related shell script programming.
Addition operations
Create a new file "addition.sh", enter the following and give it executable permissions.
Copy Code code as follows:
#!/bin/bash
echo "Enter the" number: "
Read a
echo "Enter The Second Number:"
Read B
x=$ (expr "$a" + "$b")
echo $a + $b = $x
Output results:
Copy Code co
Loops are often used in shell programming, and the commonly used loops are for and while loops. While loops read files by default in rows, and for loops read file-splitting files with spaces, this article combines some examples of current web usage and differences.
First, common grammar
1, for Loop
The syntax structure used for a For loop is as follows:
For variable in SEQ stringFor variable in ' comman
Functions simplify code and enable scripting code reuse. One definition can be invoked more than once. Structured programming to enhance readability, you can define functionality as multiple functions, then save it in a file, and then use Source (.) in ~/BASHRC or at the command line. Call this file. Speed up the operation
1. Methods of defining functions (traditional style)
function name{
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.