1. create file. sh fileIn this example, the full name of the sh file is demo.sh, and the next step is to use the freely familiar editor editor command to2. Write the. sh
#!/bin/bashwhile true; do for i in {100..120};d o ping -c 2 -w 2 192.168.0. $I &>/dev/null if [ $? -eq 0 ];then echo -e "\033[32;40m 192.168.0. $I is up.\033[0m " else echo -e "\033[32;40m 192.168.0. $I is down.\033[0m"
Sometimes you need to simply deal with the file, with a few lines of shell script statements can be done, convenient, here to remember, while the next use. Combined with other people's blog and their own practice, but also the original
Open a text editor (you can use the Vi/vim command to create a file), a new file test.sh, the extension sh (sh for Shell), the extension does not affect the execution of the script, see the name is good, if you write Shell script in PHP, the
1. Create Shell script:/home/test.shcd/home/Vim tesh.sh #linux不区分后缀,. SH is only for user convenience;The first line of the test.sh file defines the format: #!/bin/bash indicates that the file is executed with the bash shell;Content to write
& placed after the startup parameter to set this process as a background processBy default, the process is the foreground process, then the shell is occupied, we can not do other operations, for those who do not interact with the process, many times,
Shell Script Rollup 2 delete files that have been created for more than 32 days#!/bin/bash#date:2017-04-11#version:clear_ballcloud_back_v1.0#contents: removing the /www /web/ballcloud_bakck/* , if the file is created above 32 day#cd
For loopfor var in list;Docommands, #使用变量 $varDoneExampleFor I in {A.. Z}; do actions; DoneLatterFor ((i=0;i{Commands}While conditionDoCommandsDoneUntil cycleExamplex=0;Until [$x-eq 9];DoLet x + +; echo $x;DoneIf comparison statementif
$ $1-n The name of the current shell script the position variable $ #参数的数量 $* the value of all positional variables #? To determine whether the previous command succeeded, 0 for success, The non-0 is the failure---------------------------------------
Tag: Shell expression exists * * * Specify dir DIA statement return resultIf condition statement: The IF condition statement is divided into single branch structure, double branch structure, Multi-branch Structure-------------------------------------
Shell Application TipsThe shell is a command interpreter, a layer of interaction between the kernel and the kernel. There are many kinds of shells, the one with the prompt that belongs to /bin/bash, and almost all Linux Systems default to this shell.
Today to test a colleague wrote a shell script, execution of the error when the code is "Action:command not found"650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/97/EE/wKioL1k1HGHTyUhuAAAe51KKRyw564.png "style=" float : none; "title="
Type command[[Email protected] ~]# Type [-TPA] name options and parameters:: Step with any option no parameter, type will show if name is an external command or bash built-in command -T: Whenthe-t parameter is added, the type The name is displayed
1. What is a shell?The shell represents two levels of meaning, one is the command interpreter, such as BASH, and the other is a shell script (a program written using the shell's function, which uses plain text files to write some shell syntax and
Shell Programming 2First, conditional judgment statement1, according to the file type to judge Eg:test-e/etc/passwd or [-e/etc/passwd] &&echo yes | | echo no note [] There must be spaces on both sides2, according to the file permissions to
First, what is the regularA regular is a way to describe a character or string by combining symbols with special meanings, called regular expressions. Or, the regular is the rule used to describe a class of things.Second, grep1. Parameters-N: Show
One. grepgrep parameters:- n: Show Line Numbers- o: Show only matching content- Q: silent mode, no output, you have to use $? To determine the success of the execution, that is, there is no filtering to the desired content- L: If the match succeeds,
Shell program run:1./xx.sh. Running the shell this way requires the shell program to have executable permissions. chmod a+x xx.sh to add executable permissions.2, Source xx.sh.3. Bash Xx.sh,bash is a script interpreter, which is essentially an
#声明脚本#!/bin/bash#打印 "------CFB---------"echo "------CFB---------"#java环境变量Java_home=/usr/java/jdk1.8.0_11Classpath= $JAVA _home/bin#指定需要执行jar包的位置, you can set your ownJarpath=/home/haha/desktop#环境变量的标准格式Classpath= $CLASSPATH:
Multiple values can be stored in an array. The Bash Shell supports only one-dimensional arrays (which do not support multidimensional arrays) and does not need to define the array size when initializing (similar to PHP).Like most programming
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