shell scripting books

Want to know shell scripting books? we have a huge selection of shell scripting books information on alibabacloud.com

Linux--shell Programming (vi) using scripting options and combination condition testing

Write a script:1. Add 10 users user1 to User10, password with user name, but only if the user does not exist to add;#!/bin/bash# forIinch{1..Ten}; Do if!IDUser$i >/dev/NULL; ThenUseradd user$iEcho "user$i"|passwd--stdin user$iElse Echo "User$i exists" fi DoneDelete the above 10 users#!/bin/bash# forIinch{1..Ten}; Do if IDUser$i >/dev/NULL; ThenUserdel-r user$i >/dev/nullEcho "user$i deleted" Else Echo "user$i NOT EXISTS" fi DoneExtension: Adds or deletes a specif

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

Shell script Programming-case OneProgramming Requirements:1. Create a Vm-ctl script, under/bin/2. Implement features: Create a virtual machine, create a virtual machine snapshot, turn on a virtual machine, display a virtual machine, stop a virtual machine, reset a virtual machine.The script achieves the expected result:SH vm-ctl create|nodecreate|start|view|stop|reset VmnameThe implementation script is as follows:#!/bin/bashCase "$" inCreate) # #创建虚拟机

Shell Scripting Automated Collection

Remotely copy a file to the specified directory on the specified IP machine:./scp_file.sh/tmp/xx.sh/tmp/test/echo "Copy the file to the $ $ directory!" "For IP in 192.168.60.243 192.168.60.244 192.168.60.245 192.168.60.246 192.168.60.248do scp-r" [email protected] $IP: $ echo "SCP $ $ip is: $?"Doneecho "$? Distribution Complete!! "Remote execution of the specified shell file command on the specified IP machine (requires SSH support) (with parameters):

Choose login SSH using shell scripting custom implementation

Create two scripts in the system bin directory, respectively, Pssh tsshPssh#!/usr/bin/expect-fSet IP [lindex$argv 0]set Port [lindex$argv 1]set Password [lindex$argv 2]set TimeoutTenspawn ssh [email protected]$ip-P$portExpect {"*yes/no"{Send "yes\r"; Exp_continue}"*password:"{Send "$password \ r"}}interactTssh#!/bin/shEcho"here is a list of all your servers"Echo"1.A Server 192.168.100.11"Echo"2.B Server 192.168.100.12"Echo"3.C Server 192.168.100.13"Echo"0. Temporarily do not want to log in"Echo"

Shell scripting Exercises (12.12)

Write a script, create a folder, enter a folder, and then use the loop to create a sequential file in the folderIdea: 1. Create the specified folder and go to the folder2. Specify a variable with a value of 0 to allow this variable to be recycled3. Create one document at a time for Each loop until the end of the loopVim create.sh#!/bin/bash#written by Lizheng#about Create FileCD ~mkdir testfileCD testfilefor ((i=0; iTouch Testfile_$i.txtDone650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/

Shell scripting Exercises (12.8)

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 echo "z= $x-$y"Elif Test $x-gt $yThen echo "z= $x-$y"else echo "z= $x + $y"Fi650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8B/50/wKioL1hJd0rB2jlvAAALxj75lmM431.png-wh_500x0-wm_3 -wmp_4-s_3050974245.png "style=" Float:none; "title=" 333.p

Shell scripting Exercises (12.7)

Example 1. Enter any two numbers and make a judgmentVI number.sh#!/bin/bash#written by Lizhengecho "Please enter the number"Read aRead Bif test $a-eq $bThen echo "The No.2"Elif Test $a-gt $bThen echo "The > no.2"else echo "The Fi650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8B/40/wKioL1hIKCagQPMiAAAYfWCqQ_8745.png-wh_500x0-wm_3 -wmp_4-s_1863110480.png "title=" 555.png "alt=" Wkiol1hikcagqpmiaaayfwcqq_8745.png-wh_50 "/>Shell

Linux, Shell scripting Brute force user name and password

Because some registered user account rules can follow, and usually people's awareness of the poor, the password is relatively simple, the user name of the common password login test, to break the password.For learning purposes only, do not use for illegal use. The code has been partially modified, does not work properly, the test needs to modify the code according to the actual needs, in addition to the password security issues must be enough attention.Design ideas: Intercept HTTP packets

"Shell scripting Exercises" to determine user presence and user type

TopicWrite a script1. Pass a parameter to the script, this parameter is the user name;2. If the user exists, perform the following tasks* If the user's ID number is less than 500, display it as an administrator or system user;* Otherwise, display it as a normal user;3. If the user does not exist, add it;Answer#!/bin/bashUsername= $if["$username"=""]; Then Echo "Please input a username" Exit 1fiifId$username>/dev/null; Thenuserid=$ (id-u$username)if[$userid -lt -]; Then Echo "$usern

The grep command usage for Shell Scripting Learning notes

CTRL key[: Graph:] or [:p rint:] denotes ASCII 33-126 characters[: xdigit:] = 16 binary number [0-9a-f-a-f]Example:grep ^[[:upper:]] file finds lines beginning with uppercase letters in a line characterPOSIX characters need to be enclosed in [].6. Exact matchgrep "\Must have a quoted number7. Or character (extended regular expression character)Grep-e "Ou|se" matches rows with OUs or SE8.egrep and FgrepEgrep "Ou|se" fileEgrep "^-+b" file match begins with a "-" or "-" and a line containing B is

Shell Scripting Learning

Distance from the last write and a period of time, the period has been followed by private food learning, or did not develop a regular record of the habit, today to write the first script.After a few days of accumulation, learning the next shell script writing, the current master is not too mature, everything is certainly right from the beginning, write a simple bar (difficult will not write O (╯-╰) o).The way this script is executed is to enter the b

Shell Scripting Learning Notes-user input processing

: $*"(Note: e.g.--AB cannot be processed when the option is merged if the above operation can only handle a single option)2.3.4 getopt command, for option formatting, e.g:The colon after #!/bin/sh# B indicates that the B option has parameter set--' getopt ab:c ' [email protected] ' while [-N ' $ ']do case ' $ ' in-a ) echo ' Opt Ion a ";; -b) value= "$" echo "Option B, Value is $value" shift; -c) echo "Option C";; --) shift break ;; Esac Shiftdoneecho "T

Shell scripting learn to summarize the differences between--break and continue

Break is to jump out of the current loop, and continue is to jump out of the loop and start the new loop again[Email protected] test]#CatDemo.SH #/bin/Bash while true; DoRead-P"Please input number:"x yif((x>9)); ThenContinueelif((y>9)); Then BreakElseZ=$ ((x+y))Echo$zfi DoneEcho "Execution completed!"[email protected] test]#SHDemo.SHPlease input number:1 23Please input number:Ten 2 # $x >9, when the back part of the secondary loop is not executing, and the loop starts againPlease input number

Shell Scripting Learning Summary--variables and environment variables

行脚本参数的个数Echo '$*='$* #所有参数变成一个字符Echo '[Email protected]='[email protected] #所有参数basename$0 #获取文件名dirname$0 #获取文件的目录[email protected] sbin]#SH/usr/local/sbin/test.SHAA bb$0=/usr/local/sbin/test.SH$1=aa$#=2$*=AA Bb[email protected]=AA bbtest.SH/usr/local/sbinProcess state variables$? Gets the return value that executes the last command (0 is successful, others are failed)$$ getting the PID of the current shell$_ gets the last parameter of the previous c

"Shell Scripting Learning-2"

Tags:tty a regular expression devproject passwd regular penwho #!/bin/bash-#echo do what exetuate this project \nprintf "Please input your passwd" Stty-echoread Pass Shell Scripting Learning-2

Shell scripting Learn (2) compare two digit sizes

Tags: meaning cond centos7 test cat size pre BER syntax errorNote: The comparison string in the shell can only be used = =, Compare numbers using-eq,-ne,-gt,-ge,-lt,-le, or = =, [[Email protected]SH]$CatNumber_compare.SH #!/bin/bash# script Name: Number_compare.SH#用途: Compare two digit sizesEcho "Please input first number :"Read xEcho "You first number x= $x"Read-P"Please input second number:"yEcho "You second number y= $y"if[$x-eq $y]; Then Echo

The SED of Shell scripting learning

file from line 22nd to line 33rd to the end of line 44th. Sed ' 1,21h;22h;23,33h;44g ' pass 18, move the file from line 22nd to line 33rd to the end of line 44th. Sed ' 22{h;d};23,33{h;d};44g ' pass 19, only the first word of each line is displayed. Sed-nr ' s/([^a-z]*) ([a-z]+) ([^a-z]+] (. *)/\2/p '/etc/passwd 20, print the first word and the third word of each line. Sed-nr ' s/([^a-z]*) ([a-z]+] ([^a-z]+) ([a-z]+] ([^a-z]+) ([a-z]+] (. *)/\2

Shell Scripting Encryption

Think of a long time not updated blog, today in the group to see the discussion about shell script encryption things.Think about it too, we are writing scripts sometimes configure the relevant account and password things, so as long as the permission can see the information, very insecure, there is no normal operation of the file encryption. The following two features are broadly available: Encrypt files to prevent others from seeing what I w

Shell scripting basics, using variables, conditional testing and selection, and list-looping

Http://classroom/pub/materials/userlist[Email protected]/]# vim/root/batchusers#!/bin/bashIf [$#-eq 0];then//$ #位置变量的数量, when no arguments are provided, the $ #为0, the expression is setEcho ' Usage:/root/batchusers ' >2//output Usage:/root/batchusers >2 into error outputExit 1//Return value 1, prompt for wrong input parameterselif [!-F $];thenEcho ' Input file not found ' >2Exit 2FiFor a in $ (cat $)DoUseradd-s/bin/false $aEcho $a created successfullyDone########################################

Automating code deployment through shell scripting

; shell_unlock;;; *) usage;esac}main$1$2Test mode [[email protected] ~]$ Curl--head http://192.168.56.11/index.htmlHTTP/1.1 Okdate:mon, 09:42:23 Gmtse rver:apache/2.4.6 (CentOS) openssl/1.0.1e-fips php/5.4.16 mod_wsgi/3.4 Python/2.7.5last-modified:mon, 2016 09:39: Gmtetag: "17-538ff61ca0a00" accept-ranges:bytescontent-length:23content-type:text/html; Charset=utf-8[[email protected] ~]$ curl-s--head http://192.168.56.11/index.html|grep "$ OK" http/1.1 OK3. Rollback1. List rollback version 2. The

Total Pages: 14 1 .... 9 10 11 12 13 14 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.