Select is also a kind of loop, it is more suitable for use in the case of user choice.For example, we have one such requirement, after running the script, let the user go to select the number and then execute the command!#!/bin/bashselect Mysql_v in
Demand
Sometimes in the shell script needs some execution, if placed in the program is not easy to unified management, and every time you modify the path to the script inside to change the trouble, so the unified path in the configuration file
Bash is currently a more popular type of shell under Linux, and the following are some of the scattered things that are recorded in the learning process. Tidy up for forgetting!1. Transfer of function parameters1) Variables in the script that
In the execution of the scheduled task copy file, the SCP command needs to enter the password, where the public key to implement the automatic password input.Specific operation:Requirements: Copy the Test.tar on the 192.168.0.2 machine to the 192.168
1. Judging the format1) Test parameter fileExample: Test-e/root/install.log2) [parameter file]--Recommended useExample: [-e/root/install.log]Note: Spaces are required after and before the brackets2. determine file type parameters1)-D file: Determine
#!/bin/bash Fun () { Ps-ef | grep "$" | awk ' {print $ $8} ' >/usr/file and read line;d o if [[$ line = = [$]] then # does something// return fi done then Fun $ Check every five seconds to see if the process number
Batch Create files first#!/bin/shif [!-d/tmp/Chenyao]then mkdir /tmp/chenyao-p fi /tmp/Chenyao for in {1.. Ten }do touch chenyao-$i. html doneBatch Renaming[Email Protected]amp scripts]# cd/tmp/chenyao/[email protected]
Early computers because you understand the reason there are multiple physical terminals (by connecting the port of the computer what to achieve), here the terminal is the I/O device. The computer itself, which is inherently an I/O device (not an
1. File Test Actions----------------returns True if ...-e file exists-a file has the effect of this option with-e is the same. But it has been deprecated and does not encourage the use of-Ffileis a regular file (not a directory or device file)-s
1, the IP address of the regular expression: [0-9]{1,3}\. [0-9] {1,3}\. [0-9] {1,3}\. [0-9] {1,3}2. grep usageRecursive retrieval of text in a multilevel directory[Email protected] program_test]# grep "yang"./-rn./test.txt:6:laoyang./right.txt:1:1
1, the production of any size file [[email protected] dd_test]#[[email protected] dd_test]# dd If=/dev/zero of=junk.data bs=1k count=1010+0 Records in10+0 Records out10240 bytes (Ten kB) copied, 0.00137023 S, 7.5 mb/s 2, File system related test [-f
organized a few shell programming examples, for beginners! 1. InThe home directory creates 100 directories and the directory name is a1......a100. Instance 1 for((i=1; i -; i++)) Do mkdir "/home/a"$i DoneExample 2, you can also write a bit more
Use digital code to color your fonts in Linux
Font color code: Reset 0 , black, red, green, yellow, blue, magenta , Cyan, light grey Panax Notoginseng
Effect code:1m bold 2m plus underline 5m flashing effect 7m plus background color
Poptest is the only training institute for developing Test and development engineers in China, aiming at the ability of the trainees to be competent in automated testing, performance testing and testing tools development. If you are interested in
The advantage of awk for sed grep is segmentation, dividing the delimiter into a small segment, matching, replacing, manipulating, logical judging, comparing ... such asBasic operations of AWK[[email protected] ~]# awk-f ': ' {print $} ' 1.txt////-F
#!/bin/bash# @author: goooood#[email protected] #对文件名的截取分析 #file= "/dir1/dir2/dir3/my.file.txt" "# left First" " ## left greedy " " * all matches "#以第一个点删除左边echo ${file#*.} #输出: file.txt# Delete the left echo ${file##* at the last point.}
Variables are divided into system variables and user-defined variables, and their profiles are of course divided into system environment variable configuration file and user environment variable control file.1. Specify the configuration file for the
Reference documents:There are eight ways to intercept a string, mainly for the following methods650) this.width=650; "alt=" Copy Code "src=" Http://common.cnblogs.com/images/copycode.gif "/>There are a number of ways to intercept strings in the
Echo-E: Enable conversion of backslash control characters-E: Turn off the conversion of the backslash control character (this is the default)-N: Cancel line break symbol (with the \c character under the-e option agreeControl parameters Under-e
String:1. Single quotes:str = ' value 'Single-Quote String restrictions:Any character in a single quotation mark is output as is, and the variable in the single-quote string is not valid;Single quotation marks cannot appear in single quote strings
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.