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
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
Work often will write some shell script to complete the task, in the process of writing the shell often involves some arithmetic operations, below I will often use several arithmetic operation commands to do a simple summary. The commonly used
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
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
Basic usage of HBase shell
HBase provides a shell terminal to interact with the user. Use the command hbase Shell to enter the command interface. You can see the Help information for the command by performing a helper.
Demonstrate the use of hbase
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
File command to view the properties of *.sh ASCII text with the CRLF line terminators
The line end flags for Linux and Windows text files are different. In Linux, the text file uses "/n" for carriage return, while Windows uses "/r/n" to indicate
In shell scripts, the variables are global by default. So recursive calls require the local keyword to be used to display identity locals so that recursive calls to functions can be implemented. Wrote a recursive calculation of factorial script,
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