A shell process is a process that executes other processes, but when a command is executed, the shell process instructs the kernel to execute the specified program separately as another process and write the output to the terminal. With the command
1. Array definition, the shell uses a pair of parentheses to represent the array, and the array elements are separated by "spaces"
# empty array arr1
arr1= ()
# array arr2, members are 1, 2, 3, 4, 5, 6
arr2= (1 2 3 4 5 6)
2. Array elements read,
@WHILE Loop Statement @
V1=1
While ["$v 1"-lt "6"] #注 [and] have spaces around them,-lt have spaces before and after them.
Todo
echo "This is the $v 1 ' showing up"
v1=$ (($v 1+1)) #注意 $ (()) is a mathematical formula
Done
@FOR Loop Statement @
For
Function: Title
Code:
#!/bin/sh recursive () {for file in $ do subfile= ' ls $2$3/$file ' for SUBSUBF
Ile in $subfile do # echo $subsubfile if ["$subsubfile" = = "$2$3/$file"] Then RM-RF $3/$file mv $subsubfile $3/$file else
One, bash internal variables:
Common internal commands: Echo,eval,exec,export,readonly,read,shift, wait,exit, and Dot (.) are also the source commands.
Command
function
Echo Variable Name
Displays the variables
This shell script is used to obtain the MAC address of the intranet host of the 192.168.4.0/24 network segment in bulk#!/bin/bash#Author:Jink#这脚本使用ping和arp命令获取内网主机的MAC地址,查询到的MAC地址写入到文件中myping(){ ping -c2 -w1 -i0.5 $1 &>/dev/null if [ $? -eq 0 ]
In the previous section we learned about the Shell's echo command, which we'll learn from the Shell's other output command printf.The printf command mimics the printf () program in the C library.printf is defined by the POSIX standard, so scripting
If Else judgment statement If statementSyntax Format 1:if condition then statement 1 Statement 2 ... Statement NFISyntax Format 2:Often used in terminal command prompt if [conditional];then statement; fi If Else statementSyntax format:if
In daily work, the bash shell has a very frequent time operation. For example, when the shell script sends statistics periodically, it will check whether the scheduled send time is current. Or when you use a file to save some data, a time string is
1, disk use warning and send mail#!usr/bin/bash#df-th|grep '/$ ' This is the record that gets the memory used#后面两句是获取内存的使用率disk= ' df-th|grep '/$ ' |awk ' {print $ (NF-1)} ' |awk-f '% ' ' {print '} 'Mail_user=natashaIf [$disk-ge];thenecho "' Date
Guess the number game. First let the system randomly generate a number, give the number a range (1-60), let the user enter the guessing number, the input to judge, if not meet the requirements, give high or low hint, guess the right after the number
1. Modify the IP in the JSON$. IP. SH '8.8. 8.1 '#!/bin/bash#localIP =$ (command)#localip= '/sbin/ifconfig-a|grep inet|grep-v 127.0.0.1|grep-v inet6|grep 8|awk ' {print $} ' |tr-d ' addr: 'forIpinch$ ( Do if[${ip} = ="9.9.0.224" ] Then
Start password for Shell application programming. Welcome to welcome.
Description: If you want to lock access to the terminal but do not want to exit and log on again, you can write a script.Program.
When the script is called, you can exit only
ADB shell am Function
ADB shell am can use this command to start activity, services; send broadcast and so on from the CMD Console: C: \ Users \ Administrator> ADB shell AM
Usage: am [subcommand] [Options]
Start an activity: am start [-D] [-W] -D:
Netsh (Network shell)
Configure network interfaces, Windows Firewall, routing & remote access.
SyntaxNetsh [Context] [Sub-context] command
KeyThe contexts and commands available vary by platform, the list below is for Windows 2008.Use interactive
Creation: 00:49:46Author: unlinuxFrom: http://www.Unlinux.com
MeI am a newbie myself. I haven't been in touch with Linux for a long time. Recently I encountered a problem when I learned the bash Export command (the book says that export is changing
Shell itself is a program written in C language, which serves as a bridge between users using Linux. Shell is both a command language and a programming language. As a command language, it interactively interprets and executes user-input
/Etc/profile: This file sets the environment information for each user in the system. When the user logs on for the first time, this file is executed.And collect shell settings from the configuration file in the/etc/profile. d directory./Etc/bashrc:
Basically, the articles referenced below add a few items to make a record, so you are too lazy to remember them, saving you the trouble of Google every time.
Http://my.oschina.net/aiguozhe/blog/41557
1. Get the length
1
STR = "ABCD"
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