linux scripting basics

Read about linux scripting basics, The latest news, videos, and discussion topics about linux scripting basics from alibabacloud.com

Shell scripting "creation, opening, display, stop, reset of KVM virtual machines under Linux"

) # #开启虚拟机echo Start VM ...Virsh Start $ >/dev/nullEcho Start VM $ successful!!!;;View) # #显示虚拟机Echo View VM ...Virt-viewer $ >/dev/nullEcho View VM $ successful!!!;;Stop) # #关闭/Stop virtual machineecho Stop VM ...Virsh Destroy $ >/dev/nullEcho VM $ is stopped!!!;;Reset) # #重置虚拟机echo Reset VM ...Virsh Destroy $ >/dev/nullVirsh Undefine $ >/dev/nullRm-fr/var/lib/libvirt/images/$2node.qcow2 # #删除原磁盘快照文件Qemu-img create-f qcow2-b/var/lib/libvirt/images/$2.qcow2/var/lib/libvirt/images/$2node.qcow2 >/

Linux shell Scripting--Using structured commands (iii)

file Content:bin:x:2:2:bin:/bin:/usr/sbin/nologin  The done command is useful for looping the results of a loop to another command, redirecting to a file or screen, and using other commands to display to the screen[Email protected]:/data# cat Demo7 #!/bin/bashfor State in ' North Dakota ' Connecticut Illnois Alabama Tennesseedo Echo "$state is the next place to go" done | Sort > Textecho "This completes we travels" [email protected]:/data#./demo7 This completes our travels[email protecte

Linux under Bash programming combination test and scripting (v)

Linux under Bash programming combination test and write comprehensive script (v)1.Bash Programming Combination test conditions-A: With relation-O: or relationship!: Non-relationalPresentation Method 1:[$#-gt 100-a $#-le 500]Presentation method 2:[$#-gt] [$#-le 500]2. Write a script that adds and deletes users as follows:2.1: If the script option is--add:, the user will be added; If the option is--del, the user will be removed, if it is--help display

Linux Shell Scripting first experience _linux shell

Often, when people refer to the "Shell scripting language", they are bash,ksh,sh or other similar Linux/unix scripting languages emerging in their minds. Scripting languages are another way to communicate with a computer. Users can move the mouse and click on a variety of objects, such as buttons, lists, marquee, and s

Installation and scripting of the Linux graphical interface

=" Picture 19.png "style=" Float:none; "alt=" wkiol1u7t4yw2jfiaadycgbc_5c930.jpg "src=" http:/ S3.51cto.com/wyfs02/m01/6b/f4/wkiol1u7t4yw2jfiaadycgbc_5c930.jpg "/>After rebooting, click Forward, then set the time, register (click Not registered) and then restart the system again after the final completion.650) this.width=650; "title=" Picture 20.png "style=" Float:none; "alt=" wkiom1u7tivcwj-naadxhox-2ri902.jpg "src=" http:/ S3.51cto.com/wyfs02/m01/6b/f8/wkiom1u7tivcwj-naadxhox-2ri902.jpg "width

"Linux command line and Shell Scripting Encyclopedia" chapter Fourth

fileYou can also connect many parameters.such as Sort-t ': '-K 3 testYou can think of it as something inside. xxx1:xxx2:xxx3:xxx4:xxx5means to sort the xxx3-T: Specifies a character to distinguish the key position-K:--key=pos1[pos1]. The sort starts with pos1, and if POS2 is specified, it ends at Pos2.| Redirects the output of the du command to the sort command.-r: Indicates descending order.Here is an example:4.3.21. grep [options] pattern [file]For example:grep t test//Search for text in test

Linux Scripting Learn A

Linux Scripting Learning D: Delete rows that match the criteria Sed ' 1,2d '/etc/fstab delete 1, 2 lines, show other rows P: The line that displays the print fit condition Sed '/^\//p '/etc/fstab matches the display, plus the original, there will be 2 duplicateSed-n '/^\//p/etc/fstab displays the line that matches the print A: Add/string after the specified line

Linux View user Login system related commands and scripting (vii)

Linux View user Login system related commands and scripting (vii)View user log in System1.W shows who's logged in and what's being done2.who shows who logged in-R: Show System RunLevel3.sleep Sleep Command (sleep 5 sleeps 5 seconds after waking up)4.whoami display user name or UID5.last: Display/var/log/wtmp file showing user login history and System restart history-N 3: Displays information about the last

Linux Bash programming case statements and scripting (eight)

Linux Bash programming case statements and scripting (eight)1.case statement in the following format:Case variable inValue 1)Statement 1...;; Each branch statement ends with a semicolonValue 2)Statement 2...;;*) Other, equivalent if statement elseStatement 3...;;ESAC the entire case statement ends2 . Write a script that adds and deletes the user arbitrarily, with the following requirements:2.1: If the scrip

Linux Shell Advanced Programming Tips 3----Run Level scripting Introduction

file is a script that is executed when the Linux system startsEdit the Inittab file (use the Vim/etc/inittab command to open the file)Example: Add a statement to the Inittab file to allow the system to execute a shell script file that checks the system disk when it starts checkdisk.shcheckdisk::once:/sbin/checkdisk.sh >/dev/console 2>1 indicates that this command is executed at each runlevel, if it is to be developed at the third run level: Checkdisk

Introduction to shell scripting for Linux, shell script structure and execution, date command usage, variables in shell scripts

:07Variables in shell scripts You should use a variable instead when you use a string more frequently in your script and the string length is long When using conditional statements, variables are often used?? If [$a-gt 1]; Then ...; Fi When referencing the result of a command, replace it with a variable?? n=wc -l 1.txt When writing scripts for user interaction, variables are also necessary?? Read-p "Input a number:" N; echo $n?? If you don't write this n, you can use $reply

Linux shell Scripting--building basic scripts (i)

No orders found. 128 Invalid exit parameter 128+x Critical error for Linux signal x 130 Command terminated with CTRL + C 255 Exit status code out of bounds Exit Exit command can specify exit status code, but not more than 255, otherwise it will be moduloCode 1-16[Email protected]:/data# cat Demo4 #!/bin/bashdateecho $?whoexit 5[email protected]:/data#./dem

Program Ape (yuan) one of the essential skills of shell scripting: How to automatically back up MySQL data under Linux

/etc/crontab Add the following code: Here's an example of an hourly 26-minute execution: * * * * * root/home/**/wewang/autobackupmysql_qas.sh If executed at three O ' Day, then: XX 3 * * * root/home/**/wewang/autobackupmysql_qas.sh Case 2:redhat situation. ( that is, the currently used Linux system ) Copy the script you just edited to the appropriate directory [Email protected]***** wewang]# CP autobackupmysql_qas.sh/etc/cron.da

Scripting for Bash programming until statements and formatted hard disk partitions in Linux (10)

Scripting for Bash programming until statements and formatted hard disk partitions in Linux (10)1. Summary of circular statement structure1.1.while Statement Enter the Loop statement when the condition is metWhile condition; DoStatementDone1.2.until Statement Enter the Loop statement when the condition is not satisfieduntil conditions; DoStatementDone1.3.for variable in list; DoLoop bodyDone1.4.for ((expres

Scripting for special usage of Bash programming loop statements under Linux (10)

Scripting for the special use of the while statement under the Linux Bash Program (10)1. Loop control:Break: Interrupts the entire loop statement, which is the statement following the execution of the script after exiting the loopContinue: Interrupt the current cycle, advance to the next round cycleExit: End Script Run2.while dead Loop, that is, when you do not know how many times the loopFormat: while:; Do

The tenth chapter of the Linux command line and Shell scripting Encyclopedia uses the editor

Previous Edit CommandA: Append data after the current cursorO: The next line of the cursor inserts dataDW Delete a Wordd$ Delete to end of lineDD: Delete Row, 5dd delete 5 rowsThe use of backspace and delete keys in normal mode is not recognized.10.1.4 Copy and pasteDD can be pasted with p after deletion.The copy command is Y,YW copy a wordy$ Copy to end of lineThen use p to paste10.1.5 Find Replacement: s/old/new/g a line command to replace all old, which is replaced only on one line: N,ms/old

"Linux command line and Shell Scripting Encyclopedia" chapter 26th some interesting scripts

-be-sustained by perpetual neglect of many and other things. Robert Louis Stevenson (1850-1894) [Email protected]:~/shell/26zhang$ Note this:#grep "$ (date +%b '%-d, '%Y)"-A2 |Since my Ubuntu is in Chinese, I have not been searching for November. I'm going to replace it with this one, only 28, 2017.grep ", $ (date +%y)"-a2 | # Xcy AddIt would have been like this grep "$ (date +%-d, '%Y)"-A2 | # xcy Add, don't know why my date is 29. And the site is 28. May be related to the U.S. website.26.3

How does Linux modify a user's password through a script? Scripting Automation modifies user passwords?

Requirements Description :Linux environment in the creation of users, involves the modification of the user's password, generally through the passwd command to modify, need to confirm multiple times, here consider a command directly to modify the passwordThere is no way to interact. This record.Operation Process :1. Use the echo command to combine the passwd command to achieveEcho " mytest " passwd -- for user mytest. passwd: All authentication token

Linux Learning-Advanced shell scripting (a) function

, which is represented as a local variable. such as local temp=1 .Example 3. Array Parameterstest3.sh#!/bin/bash Span class= "hljs-comment" ># trying to pass a array variable function testit {local newarray # use ' local ' define a local variable newarray= (' echo " the NewArray value is ${newarray[*]} "}myarray= (1 , 2 , 3 , 4 , 5 ) echo "the original array is:${ Myarray[*]} " testit $myarray Test:sh test3.shOutput:The original array is:1,2,3,4,5The NewArray value is 1,2,3,4,5Example

Getting Started with Linux Shell scripting (ii) Looping statements

sundo Echo ' Today is $var 1 ' donefor var2 in {1..10..2}doecho ' this is $var 2 "Donefor Var3 in $ (SEQ 1 2) Doecho" I had a/an $var 3 "Donefor VAR4 in $ (LS) Doecho" Here's the file $var 4 "doneWhile loop#!/bin/bashi=1while ((I SELECT statementThis SELECT statement to the time the wood has seen, run when you can interact with the user, run the following program to understand. If you don't break it, you're going to die.#!/bin/bashecho "which color do you like?" Select Var1 in red Green Bluedoe

Total Pages: 15 1 .... 5 6 7 8 9 .... 15 Go to: Go

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.