When assigning a value of "=" to a script variable, "=" cannot have spaces left or right, otherwise it will prompt an error.For example, the following examples: #!/bin/bashbegin_time = ' date +%h: %m:%s ". /a.outend_time = ' date +%h:%m:%s ' echo ' " echo " $BEGIN _time " echo " " echo " $END _time When the system time is assigned to Begin_time and Eng_time, in accordance with the previous habit, "=" Left and right to add a space, resulting in an error message:[email pro
'; DoIf ID $DUSER >/dev/null; ThenUserdel-r $DUSER[$DEBUG-eq 1] echo "Delete $DUSER finished."Else[$DEBUG-eq 1] echo "$DUSER not exists."FiDoneFiecho "$DEBUG add: $ADD del: $DEL"[Email protected] ~]#/adminuser33.sh-v--add tom2,tom3--del tom2ADD user Tom2 finished.ADD user Tom3 finished.Delete Tom2 finished.1 add:1 del:1Exercise: Write a script showlogged.sh , which is in the following format:Showlogged.sh-v-c-h|--helpamong them, - H option can only be used alone to display help information; -
Transferred from: http://blog.csdn.net/csfreebird/article/details/7978699' symbol contains commands that can be saved to a variable after the command has been executed #!/bin/Bash v= ' java-version ' echo $v Execution Result: $./install.sh "1.6.0_34" 1.6. 0_34- B04) 20.9', English is Backtick, accent.There is another way to wrap the commands in $ (). #!/bin/Bash
Scripting of Bash functions under Linux (11)1. Function of script programming:Function: Structured programming, cannot run independently, needs to be executed when called, can be invoked multiple timesFormat 1:Function name {Statement...}Format 2:Function name () {Statement...}2. Call function Execution status return value:Format: return value, value between 0-2553. Use the function to complete the script t
# this are to show what you are to execute a series of commands in one strike.$ clear; CD/; Ls-l; echo "You is in $PWD"; echo "Time to go home"; CD ~;# Use semi colon between command.# There is also command lists, which are for a different logic# # Double ampersand means anding, double pipe means ORING; When using if only when the first command exits 0 (successful), the later command would be proceeded; When using | |, if the first command exits none of zero (not successful), the later command
'-back close or reverse closeShift +tilder? Command ExpansionCat > Lspath.txt/etc^cLs-l ' Cat lspath.txt ' | grep. conf > Etcconf.fileORLs-l $ (cat lspath.txt)Another example using "Du" command:Du-h ' Cat lspath.txt 'Set | grep EtcdirEtcdir= ' ls-l/etc 'Echo $ETCDIR # to reserve the normal format with use echo "$ETCDIR"Netstat-ant | grep 443# # # Checking HTTPS status, if result is 1, it is running; If result is 0, the HTTPS service is dead###Ssl_status= ' Netstat-ant | grep 443 | Wc-l 'Echo $ss
Write a second shell script today and write the after-class questions in "private cuisine". The problem needs to write a check whether a name exists, does not exist to create a file, there is a need to determine whether the name of the file, the file is deleted after the creation of a directory with the same name, if the directory is to delete this directory.First set up a basic condition: The Operation directory is/tmp/test/(note: If this directory does not exist you need to create manually), y
contains the information and location of the source file. Referencing a hard-link file is equivalent to referencing a source fileCp-l test1 test4The-l parameter creates a hard-link test4 that points to the file test1.Note: You can only create hard links between files on the same storage media, and you cannot create hard links between files under different mount points.The parameter-s creates a symbolic link, or a soft connectionCp-s Test TEST5When copying a linked file, be aware that if you use
Overview:Overview:This section describes the array of shell scripting in Linux, advanced string processing, advanced variables, and configuring the user's environment.One, function and positional parameter extension1. TheShift command implements the jump in the position parameter, which squeezes the leftmost parameter650) this.width=650; "src=" Http://s1.51cto.co
-proof your application and ensure that your Web application wouldContinue to support newer and better browsers.Maintainable:incorporate reusable and easily understood methods so, you and others canFocus on the business task at hand, rather than rewriting the same things over and over.Accessible:ensure that everyone can easily and efficiently access your information, even thoseWithout the script or JavaScript enabled.Usable:something that works great in one situation but was hard to implement or
51200083 linuxpartition1doesnotendoncylinderboundary./dev/sda2 64 128131024000008eLinuxLVM/dev/sda3 1281314118 1048981183Linux/dev/sda4 1411915665 12426277+5Extended/dev/sda5 141191542410490413+ NBSP;NBSP;82NBSP;NBSP;LINUXNBSP;SWAPNBSP;/NBSP;SOLARIS2, error path [[emailprotected]scripts]# ./test.shenteradiskNbsp;specialfile:hownosuchfile. [[emailprotected]scripts]#echo$?1[[emailprotected]scripts]#This article is from the "Reading" blog, make sure to keep this source http://sonlich.blog.51cto.co
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
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
Bash shell scripting Getting Started (ii)Use of the Read commandRole:Use read to assign the input value to one or more shell variables:-p Specifies the prompt to display-T TIMEOUTRead reads the values from the standard input, assigns a variable to each word, and all the remaining words are assigned to the last variableEx.read-p "Enter a filename:" FILE650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M
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
myscript.sh
You can use Set-o verbose and set-o xtrace to permanently specify-V and-O in the script header. This is useful when executing a script on a remote machine, using it to output remote information. When you should not use bash scripts your script is too long, as many as hundreds of lines you need more complex data structures than arrays there are complex escape problems there are too many string operations that do not need to invoke other p
Advanced Bash Script Programming Guide-general Linux technology-Linux programming and kernel information. Read the following for details. Advanced Bash Script Programming Guide
Main directory
Part 1. Warm up
1. Why use shell programming?
2. Start with a Sha-Bang (Sha-Bang refers #!)
2.1. Call a script
2.2. Preliminar
: Splitting files
units: Converting one unit of measure to another equivalent unit of measure (see /usr/share/units/definitions.units )
7z: High proportion of file compression
ldd: Dynamic Library Information
nm: Extracting symbols from the obj file
ab: Performance Analysis Web server
strace: System Invoke debugging
mtr: Better Network Debug Tracking tool
cssh: Visual concurrency Shell
rsync: Synchronizing files and folders via SSH
wiresharkand tshark : Grab bag and network
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.