We can pass parameters to the script when executing the Shell script, and the format of the parameters obtained in the script is:$n. n represents a number, 1 is the first argument to execute the script, 2 is the second argument to execute the script,
#!/bin/bash # Check if the 192.168.1.1-192.168.1.254 host is aliveFor IP in 192.168.1. {1..254};DoIf ping-c 1 $ip >/dev/null; Thenecho "$ip OK."Elseecho "$ip no!"FiDone#!/bin/bash #检查多个域名是否可以访问Url= "www.baidu.com www.sina.com www.jd.com"for URL in
Http://www.1987.name/141.htmlShell Basics
Terminal printing , arithmetic operations , frequently used variables
Search for a specific string under the specified folder and highlight matching keywords under Linux
Get standard input from a
File judgment operator–b return True when file exists and is a block file-C Returns True when file exists and is a character-D returns True when pathname exists and is a directory-E Returns True when a file or directory specified by pathname is
OneHttp://www.cnblogs.com/GarveyCalvin/p/4301235.htmlTwoForeword: Zsh can be configured strong, user can customize the configuration, personalization is strong. Zsh Tab Completion is more powerful, this feature allows us to save a lot of time. Zsh
Bo main name: Li ChangmingBlog Address: http://keep88.blog.51cto.comThis note is from the old boy books: Learn Linux OPS Shell programming with old boysSpecial extension variables1. ${parameter:-word} Functional PracticeThe role of ${parameter:-word}
Recently wrote a small program, need to use time. Traverse as part of a folder#!/bin/bashfor i in {1..30}dodate= ' date +%y/%m/%d-d "$i days Ago" ' Echo $datedoneFor loop, take the date of the recent n days.The core isDate= ' Date +%y/%m/%d-d ' $i
Shell Authoring Steps:1. Scripting Vim first.sh2. Write the complete test script Bash-n first.sh3. Granting permission chmod +x first.sh4. Execute the script./first.shPS Shell Script Learning first need to understand Linux, system commands and
Shell's sed command to delete a variable with a "date time and so on" methodThe SED command deletes the specified content and may be known, for example, if you want to delete the line containing "Badboy" in a file, use the following command directly:
String slices:${var:offset:number}Offset: The number of strings to skipNumber: The string to be fetchedCases:Name= "Obama"${name:1:2}--Displays the result as Ba${name:1}--Displays the result as BamaTake the rightmost few characters of the string:
Find File LookupFind txt and PDF filesFind. \ (-name "*.txt"-o-name "*.pdf" \)-printFind files that start with all lettersFind. -name "[a-a]*"Find all non-txt text with negative parametersFind. ! -name "*.txt"-printSpecify the search depth to print
When you need to automatically answer the ' yes ' or ' no ' options in your script, you can invoke the Yes gadget with the following syntax:such as (for each query raised during the execution of a command behind a pipeline, send a custom content no
2013.05.10 MyTask 1.2The main program sleep time is divided into several small fragments of time to sleep, to avoid prolonged hibernation can not respond to the system signal in time.2013.05.07 MyTask 1.1After releasing the mytask1.0 version
DevelopmentShellscripts are implemented with script arguments , respectively, andReadRead inthe way to compare2an integer size. Use conditional expressions (prohibitif) and remind the user to compare the results in the form of a screen output. Note:
In the shell, send a signal to the process a lot through the CTRL key plus some function keys to achieve, here is the common CTRL key combination and its meaning:
Key combinations
Signal type
Significance
CTRL +
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.