Learn more about the character test of Linux and the practice of bash scripting
One, character test options
= =: Tests whether two strings are equal, equals true, and not equal to false.
! =: Tests whether two strings are unequal, unequal to true, and equal to false.
-N String: Tests whether the specified string is empty, NULL is true, and is not NULL for false.
-Z String: Tests whether the specified string is not empty, is not empty, is true, and Null is false.
Second, complete the following bash scripting exercises
Exercise: Write a script
Pass a parameter (single-character on line) to the script, such as Q, Q, quit, or quit, to exit the script, otherwise, the user's parameters are displayed;
#!/bin/bash
#
if [$ = ' Q '];then
echo "Quiting ..."
Exit 1
elif [$ = ' Q '];then
echo "Quiting ..."
Exit 2
elif [$ = ' Quit '];then
echo "Quiting ..."
Exit 3
elif [$ = ' Quit '];then
echo "Quiting ..."
Exit 4
Else
echo $
Fi
Write a script:
Determine the current host CPU manufacturer whose information is in the Vendor ID row in the/proc/cpuinfo file.
If its manufacturer is AUTHENTICAMD, it will be shown as AMD;
If its manufacturer is Genuineintel, it will be displayed as Intel Corporation;
Otherwise, it is said that it is a non-mainstream company;
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/43/AD/wKiom1Pbtt6R7DUgAACoC1g0soY233.jpg "title=" 36020140801234201757.jpg "alt=" Wkiom1pbtt6r7dugaacoc1g0soy233.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/43/AD/wKioL1Pbt9_xNVKDAAAg3jAbCUg703.jpg "title=" 36020140801234222299.jpg "alt=" Wkiol1pbt9_xnvkdaaag3jabcug703.jpg "/>
Practice:
Pass three parameters to the script, the first is an integer, the second is an arithmetic operator, the third is an integer, the result of the calculation is displayed, and the two-bit precision is required to be preserved. Shaped like:
./calc.sh 5/2
#! /bin/bash
echo "scale=2; $1$2$3 "| Bc
This article is from the "lost the year of the Sao" blog, please be sure to keep this source http://8855546.blog.51cto.com/8845546/1533997