The difference between source test.sh and./test.sh is that source can use the variables of the test.sh script after the script is executed, and./test.sh, its variables can only be used in scripts.Variables can be divided into global variables, local
Twenty. To get the system run data through the pipeline Combination shell command :1. Output the 5 most memory-intensive commands in the current system:#1) Lists all the processes that are running on the current host through the PS command.#2) The
Regular expressions
Used primarily for pattern split/match/Find and replace operations on strings.
Regular expressions and wildcard characters
Wildcard charactersThe difference between a regular and a wildcard:
A regular match string
Organized a number of shell-related exercises, recorded here.1. Please follow the date format xxxx-xx-xx to generate a daily file, for example: The file generated today is 2013-09-23.log, and the use of the disk is written to this file.1 #!/bin/bash2
Script 1 Stop Lampp#!/bin/bash#set-XV Open debug mode?Count= ' Ps-ef|grep lampp|grep-v "grep" |wc-l ' # "" is the TAB key that holds down shift to appear ~ symbol, excluding the command count lines of grep itselfIf [$count-GT 0] # greater than one
Shell in && | | Usage && operator: command1 && command2 && Left command (Command 1) returns True (that is, returns 0, successfully executed) after,&& The command on the right (command 2) can be executed, in other words, "If this command executes
CMD is also a shell of Shell windowns.View files and folders dirmkdir * * * Create folder Rd* * Delete folder (should have parameters, recursion, etc.)Ctr+c Abort Commandcd>***.** Creating a file del filename Type + relative path view
#!/bin/bashread-p "Please enter the number of start:" Minread-p "Please enter the number of terminations:" Maxif [$min-gt $max]thenecho "Start number is greater than the number of terminations! "Elseecho-n" random number: " ; expr $ (date +%n)% $[
#! /bin/bashecho-n Input year to judge if it was a leap year:read yearlet "y1= $year% 4" let "y2= $year%" let "y3= $year% 4 XX "If [! "$y 1"-eq 0]thenleap=0elif [! "$y 2"-eq 0]thenleap=1elif ["$y 3"-eq 0]thenleap=1elseleap=0fiif ["$leap"-eq
1. Shell basic format, variable# Add an interpreter to the shell script #! /bin/bash# Print out Hello world with a script#! /bin/bashecho "Hello World"ExitParameters: A parameter is an entity that stores real values that are typically referenced in
Shell expressionWhether the-D file exists and is a directoryThe-f file is present and is a normal fileWhether the-W file file exists and is writable-s file exists and is not empty-N string string length not 0String1=string2 string Equality-eq equals-
Technorati tag: Shell,df,sed,awk -Monitor System statistics
Monitor disk free space
Disk Resource Usage
Monitor CPU and Memory usage
-Perform a backup
Archive data files
Offline Storage of Backup files
Enter 2 numbers (x, y) if x equals Y, the output is z=x+y, if x is greater than Y, the output is z=x-y, otherwise the output z=x+yVI number2.sh#!/bin/bash#written by Lizheng#about Panduanecho "Please enter the number"Read XRead Yif test $x-eq $yThen
The company now needs to make regular backups of the existing servers and place the backup files in the NAS being used;For the efficiency of backup, we also need to filter the backup files and exclude some files with suffix names.The implementation
1. Batch generation of random character file name casesUse the For loop to bulk create 10 HTML files in the/sixijie directory, where each file needs to contain 10 random lowercase characters plus a fixed string sxj, with the following name examples:[
First, demonstrate the effect of rebound shell0. Look at the Python version650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/8B/90/wKioL1hRTinAlo_nAAASu8q0u_A128.jpg "title=" Python.jpg "style=" Float:none; "alt="
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.