"Linux Shell Script Raiders" note chapter I: Shell starting base

Source: Internet
Author: User


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

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.