Linux Shell Script Raiders notes
Chapter One: Shell start -up basics
1. Variables: In bash, the value of each variable is a string. Whenever you assign a value to a variable, there is no quotation mark, and the value is stored as a string. 2, Var=value; Assignment operation var = value;//equal action 3, gets the length of the string [[email protected] ~]$ Var=yang[[email protected] ~]$
length=${#var}
[Email protected] ~]$ echo $length
44. Several methods for solving arithmetic operations: [[email protected] program_test]# cat easy_calc.sh
#! /bin/bash
A=1
b=2
Rst1=$[A + b]
Rst2=$ ((A + B))
rst3= ' expr 1 + 2 '
echo "rst1= $rst 1"
echo "rst2= $rst 2"
echo "rst3= $rst 3"
5. redirect [[email protected] program_test]# ls + 2 &> outerr.txt
[[email protected] program_test]# ls + 2 > Out2err.txt 2>&1
[Email protected] program_test]# diff outerr.txt Out2err.txt
[Email protected] program_test]#
6,/dev/null is a special device file, any data received by this file will be discarded.
7, modify the debug #!/bin/bash to #!/bin/bash-xv//equivalent to turn on the Start debugging function.
8, Read-p//read. [Email protected] program_test]# read-p "Please input:" var
Please Input:laoyang
[Email protected] program_test]# echo $var
Laoyang
Ming Yi World
Reprint please indicate source, original address: http://blog.csdn.net/laoyang360/article/details/42364615
If you feel this article is helpful, please click on the ' top ' support, your support is I insist on writing the most power, thank you!
"Linux Shell Script Raiders" note chapter I: Shell starting base