Discover linux command line and shell scripting bible, include the articles, news, trends, analysis and practical advice about linux command line and shell scripting bible on alibabacloud.com
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 ob
If a system administrator spends a lot of time solving problems and doing repetitive work, you should wonder if he is doing the right thing. An efficient system administrator should make a plan to spend as little time as possible on repetitive tasks. So while it looks like he didn't do a lot of work, it's because the shell script helped him do most of the tasks, which is what we're going to explore.
What is a
Basics of Linux Shell scripting here we first talk about the shell of the basic syntax, the beginning, comments, variables and environment variables, to do a basic introduction, although not related to specific things, but lay the foundation is to learn easily after the premise.
1.
1. Linux Scripting Basics1.1 Basic Introduction to grammar1.1.1 StartThe program must start with the following line (must be placed on the first line of the file):#!/bin/shThe symbolic #! is used to tell the system that the parameters behind it are the programs used to execute the file. In this example we use/BIN/SH to
[Turn]http://www.knktc.com/2011/08/20/linux-shell-expect%e6%89%b9%e9%87%8fscp%e8%84%9a%e6%9c%ac%e5%b7%a5%e5%85%b7/
One of the most recent tasks in preparing a deployment is to send some files, such as installation packages, to a large number of servers. Although there is already a Brother Woo script available: A Python script written by the SSH and SCP features provided by the Paramiko module. But I'm stil
The Linux system processes each object as a file. This includes the input and output processes. Linux uses file descriptors to identify each file object. A file descriptor is a non-negative integer that uniquely identifies the open file in the session. Each procedure can have up to 9 file descriptors at a time. For special purposes, the bash shell retains the ear
Bit left shift
>>
Bit right Shift
Bit Boolean and
|
Bit Boolean or
Logic and
||
Logical OR
Code 2-11[Email protected]:/data# cat Demo3 #!/bin/bashval1=10if (($val 1 * * 2 >) then ((val2= $val 1 * * 2)] echo "The sq Uare of $val 1 is $val 2 "Fi[email protected]:/data#./demo3 the square of 100 use both brackets[[Expression]] provides another feature
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
used with variable names, and if the loop body does not include a variable name, a dead loop may occurHow the list is generated:1) Give a direct2) List of pure integersSEQ: Output An integer listseq [First [INCREMENT]] Last3) curly braces unfold{first.. Last}4) return value of the execution result of the command5) GLOBBING6) references to certain variables: [email protected], $*Features of the For loop:1. There is almost no cycle of death;2. The entire list needs to be loaded into memory during
command. You can use Echo to print any variable value in any place where you suspect it is wrong. That's why most shell programmers spend 80% of their time debugging programs. of the Shell programThe advantage is that there is no need to recompile, and it does not take much time to insert an echo command.The shell also has a real debug mode. If there is an error
1. After opening the terminal prompt, $ represents a normal user, #表示管理员用户root, root is the most privileged user in the Linux system.2. A shell script is usually a text file with a #! start, where #! precedes the interpreter path. Example: #!/bin/bash3. Note section starts with #, and consistently continues to the end of the line4. By default, Echo adds a line br
results of "mail.jpg tux.jpg".quotation marks (single and double quotation marks) prevent this wildcard extension:
#!/bin/shecho "*.jpg" Echo ' *.jpg '
This will print "*.jpg" two times.Single quotes are more restrictive. It prevents any variable expansion. Double quotes prevent wildcard expansion but allow variable expansion.
#!/bin/shecho $SHELLecho "$SHELL" Echo ' $SHELL '
The result of the operation is
makefile compiled files./configure--prefix=/usr/local/apache--with=/aa/cc--prefix Specify installation directory,--with specify dependent file directory2.make Compiling makefile FilesMake also needs to be installed, yum install Make,makec,makeg3.make InstallMake install copies the compiled files to the directory specified by--prefix, if not specified, is the current directoryLinux related directory file storage content:The bin is stored in a normal program and can be used by all usersBoot stora
-nand 11 use, tell read command to accept single word specifier exitCode 2-25[Email protected]:/data# cat Demo5 #!/bin/bashread-n1-p "Do you want to continue [y/n]" Answercase $answer in y|y) E Cho echo "fine,continue on ...";; N|n) echo echo "Ok,goodbye" exit;; Esacecho "This is the end of the script" [email protected]:/data#./demo5 does you want to continue [y/n]yfine,continue on]. . This is the end of the script Hidden mode read, the-S optio
Linux shell scripting:1. Program Structure Exercise: Write a script, given a positive integer, to calculate the sum of all digits of this number.For example, if the program is given input 123, it should return 1+2+3=6.2. Program Structure Exercise: Write a script, given a positive integer, to output this number in reverse order.For example: program input 123, the
TopicShell Scripting Knowledge points: What are trap signals in Linux system scripts and how are they used?Reference answer: "Trap signal Command description"The trap command is used to specify the actions to be taken after a signal is received, and a common use of the trap command is to complete the cleanup work when the script is interrupted.Historically, the shell
Tags: linux operations computer network Dahne Red Hat Linux system operationShell ScriptScript: Can execute the file, after running can implement some function (command stack, non-interactive)Standardize the general composition of shell scripts#! Environmental Statement (Sha-bang)# comment TextExecutable code#! /bin/bash #环境声明 that the script written by Bash is a
The remaining space is Morethan the%, the message is sent to the Wl#tue2 the: $: AboutCst .PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/wl/Binexport PATH forRemainingspaceinch$(DF-H |awk '{print $}'|grep-V' Use'|sed-E's/[%]//g') Do if[[$RemainingSpace > the]]; Then Echo-E"$RemainingSpace" Echo-E"$ (df-h | grep $RemainingSpace)">/service/script/. Harddiskwarning Mail-S"Disk Warning"WL . Harddiskwarningfi Done4. Detecting remaining Inode#!/bin/Bash#inspcet Inode
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.