Read about unix shell scripting commands pdf, The latest news, videos, and discussion topics about unix shell scripting commands pdf from alibabacloud.com
32428.7 Summary 32429th CGI Script 32529.1 What is a Web page? 32529.2 CGI 32529.3 connecting to a Web server 32629.4 CGI and HTM scripts 32629.4.1 Basic CGI Script 32629.4.2 Show shell command output 32829.4.3 using SSI 33029.4.4 Access Counter 33029.4.5 uses a link to display the current webEnvironment Variables 33229.4.6 Other common environment variables 33429.5 get and Post methods Introduction 33529.5.1 Get Method 33529.5.2 Post Method 34029.5.
Scripting programming languages and compiled languages:
Scripting programming Language: (Bash)
The scripting language is usually interpreted (interpreted), which is read into the program code primarily by the interpreter (interpreter) and is translated into an internal form for execution.
Advantages:
can easily handle objects such as files and directories.
D
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
2 3
Do
For var2 in 0 5
Do
if [ $var 1 -eq 2-a $var 2 -eq 0 ] /c0>
Then
break 2
Else
Echo "$var 1 $var 2"
fi
Done
Done
As above, break 2 means to jump out of the outer loop directly. Operation Result:1 01 5Continue commandThe continue command is similar to the break command, with only a little difference, and it does not jump out of all loops and just jumps out of the current loop.To modify the above example:
#!/bin/bash
While :
Do
echo- n "Input a num
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#./de
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
:
Traverse:
For ip_t in ${servers[*]};d o If ["$" = "$ip _t"];then is_ip_correct=true break FidoneCall other programs:
Use ', and get the output result:
ps3= "Please choose a branch:" Select Branch in' svn list svn://;d o if [$branch];then svn_dir= "svn://
using $ (), and obtain the output result:
today=$ (Date+%y-%m-%d/%h:%m:%s)svn_version=$(SVN info $SVN _dir | grep "Last Changed Rev:" | awk ' {print $4} ')
Invoke other programs silently (with
-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
{Command1Command2Command3}CommentsAs with the shell, the comment uses the #Replace[Address] S/pattern/replacement/flagsThis means that the part of the address line that matches the pattern is replaced with replacement.Of these, flags have several values:A number from N 1 to 512 that represents the substitution of the nth occurrence of the specified pattern in this mode.G makes a global change to all occurrences of the pattern space, and by default onl
]:~/learn$ cat Args.txt | Xargs SH cecho.sh;Arg1 arg2 arg3#Requirement 3, how do I embed parameters in a fixed command line? As shown below:Copy CodeThe code is as follows:[Email protected]:~/learn$ sh cecho.sh-p args1-1-P args1-1#[Email protected]:~/learn$ sh cecho.sh-p args2-1-P args2-1#[Email protected]sli-pc:~/learn$ sh cecho.sh-p args3-1-P args3-1#Solutions for using Xargs:Copy CodeThe code is as follows:[Email protected]:~/learn$ cat Args.txt | xargs-i {} sh cecho.sh-p {}-1-P arg1-1#-P arg
Many programs impose some logical control processes on the commands in shell scripts.Structured commands allow you to change the order in which programs are executed. It's not necessarily in sequence.12.1 using the If-then statementThe following format:if commandThenCommandsFiThe IF statement will allow the command after the IF, if the command's exit code of 0 (w
Today, let's learn about Common Unix shell commands. We all know that Unix shell is not only a user interaction interface, but alsoProgramDesign Language: when the system registers, it will execute a Unix
Text processing commands for Shell scripting Learning notesA. Cut (truncate text characters or field fields)Command format: Cut [option] FileCombined use of 1.-d and-F to intercept fieldsDescription: * denotes delimiter, such as-,:, empty characters, etc.n Denotes nth fieldUsage One: cut-d*-fn to intercept a field from the text for each line that is delimited by
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.