Linux variables are roughly divided into four categories: User-defined variables, environment variables, positional parameter variables, predefined variables four categories, the most commonly used is the first three categories, where positional
$: The script name, relative path, or absolute path depends on how the call is being invoked. If the./dollartest.sh call is in the parent directory, then $ is./dollartest.sh, if it is a full path call, such as "/root/test/dollartest.sh", then $ is "/
Both $* and $@ variables provide fast access to all parameters, both of which can store all command-line arguments in a single variable.
The $* variable saves all parameters provided on the command line as a single word and is treated as a single
Let's take a look at the return value of the two functions to get the way:
#!/bin/bash
#函数返回值获取测试.
function fun_test ()
{
#在函数内部是不能有其他的任何一条打印语句.
Echo
}
val=$ (fun_test)
echo $val
Another one:
#!/bin/bash
#函数返回值获取测试.
function fun_test
how Shell arrays operate
number of array elements ${#array [@]}
all elements of an array ${array[*]}
string length ${#str}
1, get the number of elements of the array:
array= (Bill Chen Bai Hu);
num=${#array [@]}///Get the number of array
Use in shell programming to determine parameters within the IF statement
–b returns True when file exists and is a block file
-C Returns True when file exists and is a character file
-D returns True when pathname exists and is a directory
-E Returns
In the Linux shell command expr is not very noticeable, but it works very well. So far, I personally think the biggest role is two-arithmetic and string operations.
First said arithmetic, in the shell arithmetic not simple subtraction, should write
1 PATH environment variable
2 Use of redirects
0 Callout Enter default keyboard input, you can use other content to redirect the correct output on the 1 standard output screen
2 error output &> redirect
all output
redirection symbols are:
> >>
2
The time display command under Data Command Linux, not the Times command, which is the timing command for the commands:
Man date ...%m Month (01..12)%m minute (00..59)%n a newline%N nanoseconds (000000000..999999999)%p locale ' s equivalent of
Paste:
http://blog.csdn.net/allenlinrui/article/details/7490206
With Crontab you can execute a shell script or a series of Linux commands at a specified time. For example, the system administrator schedules a backup task to run every day
Getting
First, the user login into the system after the system environment variables:
$HOME user's own directory
$PATH directory to search for when executing commands
$TZ Time Zone
$MAILCHECK every few seconds to check for new letters
$PS 1 The prompt
For example, the
script name is called test.sh Three: 1 2 3 is as follows
./test.sh 1 2 3
After running test.sh 1 2 3
$* is "1 2 3" (enclosed in quotes)
$@ is "1" "2" "3" (wrapped separately)
$ #为3 (number of parameters)
Case 2:
Experimental three shell program design: Shell Foundation
Experimental purposes:Further consolidate the basic grammar of Shell programming language and deepen the understanding of the learned knowledge.
Experimental requirements1. Use of four
With the popularity of Docker, the application of Docker is more and more, the work is certainly not necessary, but the individual feel that some of Docker commands require a bit more parameters, such as running a container, –name to the container
a function
There is no obvious difference between a function and a shell script, but there is an essential difference in execution:
for a separate shell script, create a new shell process for it when executing, and interpret and execute the code in
Just started contacting the mongdb shell. Here is a record of the learning process.
Open the shell in the console.
Linux Environment:/usr/local/mongo/bin/mongo
Window Environment: D:\mongodb\mongodb-win32-i386-2.0.6\bin>mongo
The basic section
Using variables from the shell in awk
One: "' $var '"
In this way, you don't have to change the habit of using the AWK program, which is commonly used by foreigners. Such as:
var= "Test"
awk ' begin{print ' $var ' "} '
This notation is actually a
Transferred from: http://www.cnblogs.com/penghong2014/p/6065838.html
1. First download historian.py script, download address: Https://github.com/google/battery-historian2. Unzip the download and go to the
ObjectiveWe have successfully installed the Linux system--centos7, and now follow the super brother to the gate of Linux.So!Start a picture, equip all by dozen ...What the hell is this black one?Using Linux every day, is to open the virtual machine,
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