Example No. 2As a shell writer, often face the problem of inconsistent data format, the data standard session output is a need to solve the problem, this example takes MySQL time as an example, the script enters the month, the day, the year three parameters, standardized after the output, the month in English standard
/fixup.responseEnable file being used is:/tmp/cvu_11.2.0.3.0_grid/fixup.enableLog File Location:/tmp/cvu_11.2.0.3.0_grid/orarun.loguid=501 (GRID) gid=501 (Oinstall) groups=501 (Oinstall), 502 (DBA), 503 (Asmadmin), 504 (ASMDBA), 505 (Asmoper)[Email protected] ~]#/tmp/cvu_11.2.0.3.0_grid/runfixup.sh-- in the node 2 Run script onResponse file being used is:/tmp/cvu_11.2.0.3.0_grid/fixup.responseEnable file being used is:/tmp/cvu_11.2.0.3.0_grid/fixup.en
also be written # # ########################################################################CD $LOG _dir | | {echo "Cant" to necessary directory. ">2 # >2, which is 1>2, redirects the standard output to a standard error. But it's all the same here. Indicates that the previous command execution failed after the execution of the following command. If the previous command executes successfully, the subsequent command does not execute.Exit $E _xcd;}##################################################
users user1 to User10, but require that only the user does not exist to addAnswer:#!/bin/bashFor I in ' seq 1 ';d ocut-d:-f1/etc/passwd |grep "user$i" 2>>/tmp/etc.err | | Useradd user$iDoneJob Four: Write a scriptTest whether all hosts between 192.168.0.151 to 192.168.0.254 are online through the ping commandIf online, "IP is Up" appearsIf the line is not present, "IP is Down"Answer: #!/bin/bashFor I in ' SEQ 151 254 ';d OPing-c1-w1 192.168.0. $I >/dev/null echo "192.168.0. $I is up" | | echo
eth0 | grep "TX Pack" | awk ' {print $} 'Sleep 1Done19. Use the list of people in the User.txt file to automatically create the corresponding account and configure the initial password on the computer#!/bin/bash#本脚本执行, you need to prepare a user.txt file in advance that contains several user name informationFor i in ' Cat User.txt 'DoUseradd $iecho "123456" | Passwd‐‐stdin $iDone20. Write bulk modify extension scripts, such as batch to modify TXT file to doc file#!/bin/bash#执行脚本时, you need to a
Shell script example: calculate the time difference in milliseconds and microseconds, and shell microseconds
You can use the time command to calculate the execution duration of a command. Although the time command can be precise to milliseconds, the time command cannot calculate the execution time of a bunch of commands. You can also use the date command to calculate the time difference before and after the
, randomly generated within 10 of the number, to achieve the word guessing game, the hint is relatively large or small, equal to exit.#!/bin/bashread-p "guessnumber!pleaseenteranumer{0-10}:" nif[[ $n =~^[[:d igit:]]+$]];theni=$[$RANDOM%11] until[ $n -eq $i ];do if[ $n -gt $i ];then echo "It ' stoolarge" else echo "It ' stoosmall" fi read-p "Tryagain:" n doneecho "Youareright!!!" elseecho "pleaseinputanumber!!! " Fi650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/86/21/wKioL1e1gXygM0L
: global s s = Socket.socket () host = Socket.gethostname () S.bind ((host, 60123)) except: print (' already have an Instance ... ') return None return func (*args,**kwargs) return fun@applicationinstancedef main (): While True: print ' running ... ' time.sleep (1) if __name__ = = "__main__": Main ()Iv. Summary(1) Daemon and single script running in
A shell script error often occurs when writing a script: write it in windows and copy it to execute it. However, an error is reported when you test it, the error is amazing. for example, the syntaxerrornearunexpectedtokendo error occurs in my for loop statement. be careful... A shell script error often occurs when writ
In the previous two articles, the basic syntax of static arrays and dynamic arrays is briefly introduced, and an example is illustrated in this article for the use of arrays in daily operations.First, the demandIn the customer organization has replaced the antivirus software vendor, need to scan the server or whether the client installed anti-virus software, or whether the installation of excessive anti-virus software.Second, the solution of ideasWe p
The site data draw contour needs to first interpolate the site data to the lattice point data, meteoinfo the inverse distance weights (IDW) and Cressman two methods, wherein IDW method can have the option of interpolation radius. Here The example reads a micaps first class of data (ground full-feature observations), obtains 6-hour accumulated precipitation data (precipitation6h), and then uses the Griddata function of the site data to interpolate the
Script Script Description:
The first step: Add the following code to the Here separated by Spaces^a great search engine from the makers of aol!*http://java2000.126.com~java2000
Collections|java javascript Search HTML download CGI perl DHTML Games ActiveX download script ^coolest Java and
JavaScript collections for Internet surfers to enhance web page!
*http://www
Translated from: http://www.zccode.com/forum.php?mod=viewthreadtid=637extra=page%3D1NET Fox 6603 Special Database Weight Loss effect script (18G into 300M) is as follows:Copy script statements to SQL Server new query, execute, clear redundant log/** Database Super Weight loss, 18G can become 300M.*/--Truncate The log by changing the database recovery model to simple.Use QptreasuredbALTER DATABASE Qptreasure
Shell script example: Batch compare whether the content of multiple files is the same,
To compare whether the content of the two files is completely consistent, you can simply use the diff command. For example:
diff file1 file2 >/dev/null;echo $?
However, the diff command can only specify two file parameters. Therefore, it is impossible to compare multiple files
Linux/etc/init. d/service script example, etcinit. d
1. Write the script and put it in the/etc/init. d/directory, and set the executable permission chmod + x scriptnamed.
2. The script contains several methods: start, stop, restart, and status,
The/opt/myservice. sh script c
Please implement a js script, which requires that the number be converted into kilobytes, for example, 10000 is converted to 10,000Implement a js script to convert the number into a kilobytesFor example:10000 ----> 10,000
10000121213 ----> 10,000,121,213
I accidentally saw this question today and thought about four sol
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.