Shell Introduction
Shell is simply a command parser that converts user-input commands into programs that can be executed by corresponding machines.
A Shell script is a text file (batch processing) that contains a series of command sequences ). When you run this script file, the command sequence contained in the file will be executed.
HelloWorld
The first line of
/*************************************** ******************************* Author: Samson* Date: 08/01/2013
**************************************** ****************************/
BASH Shell script programming learning summary:
Variable:(1) environment variables: can be modified;(2) internal variables: provided by the system and cannot be modified;$ #: Get the number of parameters$? : ShellProgramReturn
frequently and do not need to be used when interacting )This method of assignment, which is followed by the argument directly behind the command, is then used by the system to refer to the first parameter.The fourth method is to use the output of the command to assign a value ( This method of assignment can directly process the data generated by the previous command )In a shell program, you can use the output of a command as a variable, but you'll ne
In the first two articles, we have mastered some of the basic syntax of the shell, the use of variables, and the operation of basic data types. So this time we will learn the shell's structured commands, which are conditional selection statements and looping statements in our other programming languages.However, when you learn shell-structured commands, we will f
One: Program concept? Program: Algorithm + data structure? data: Is the core of the programData structure: The type and organization of the information in the computer? algorithm: How data is processedProgram Programming Style:Program: command-centric, data-serving instructionObject type: Data-centric, instruction serves dataAdvanced Programming Languages:Compiled: High-level language--compilers--machine co
The use of conditional expressions in shell programming
If conditionThenCommandElseCommandFi, don't forget this ending.
If statement forgets the end fiTest.sh:line 14:syntax error:unexpected End of fi
Three conditional expressions of IF
IfCommandThenIfFunctionThen
Command executed successfully, equal to return 0 (such as grep, find a match)Execution failed
Linux programming: Use PHP as a Shell script-general Linux technology-Linux programming and kernel information. For details, see the following. We all know that PHP is a very good dynamic web page development language (fast speed, short development cycle ......). However, only a few people realize that PHP can also be a good language for writing
Shell login mode, shell arithmetic operation, Shell logic operation, shell condition test, Shell selection statementShell programming in the first line indicates the path of the shell t
interface with BASHBASH provides a small statement format that allows the program to quickly design a menu of user interaction choices for a character interface that is implemented by the SELECT statement, with the syntax of the SELECT statement:Select Var in
; Do. Here is an example of using a For loop:#!/bin/bashFor day in Sun Mon Tue Wed Thu Fri SatDoEcho $dayDone# If the list is contained in a pair of double quotes, it is considered an elementFor day in "Sun Mon Tue Wed Thu
: Shell internal system variable random generates an integer number between 0~32767)Code:#!/bin/bashRead-p "Please input a number between 0 and:" xtemp=$ ((random%100))While [$x-ne$temp]Doecho "fail! Try it again! "If [$x-gt $temp];thenRead-p "Please input anumber smaller:" xElseRead-p "Please input anumber larger:" XFiDoneIf [$x-eq $temp];thenecho "Congratulations!"Fi:Summary: This experiment took a long time to complete it, unfortunately, did not co
1. Unix Shell functions A shell is a program that manages processes and runs programs. All the common shells have 3 main functions: (1) running the program; (2) Managing inputs and outputs (3) Programmable The shell is also a programming language with variable and process control. 2. UNIX Process Model A program is a
Shell Authoring Steps:1. Scripting Vim first.sh2. Write the complete test script Bash-n first.sh3. Granting permission chmod +x first.sh4. Execute the script./first.shPS Shell Script Learning first need to understand Linux, system commands and general structure familiar, able to skilled operating system and build common services to provide services, to better learn shel
Chapter 2 why do I need to pass parameters to shell scripts when passing parameters in shell programming basic scripts? Parameter passing can pass External amp; 20540; to the internal functions of the script to improve the flexibility of the script. parameter passing can add applicable options of the script to increase the customization of the script, in order t
Shell Programming:Compilers, interpretersProgramming languages: Machine language, assembly language, advanced languagesStatic language: Compiled languageStrongly typed (variable)Convert into executable format in advanceC, C + +, JAVA, C #Dynamic language: Interpreted language, on the flyWeak typeEdge Interpretation Side ExecutionPHP, SHELL, Python, PerlProcess oriented:
Shell programming variables a bash variable and variable classificationBash is a standard shell in Linux, so it's often called bash as a shell.1. Variable naming rules
Variable names can consist of letters, numbers, underscores, but must begin with a letter and an underscore;
The length of the variable nam
Every programmer working on Unix/Linux may be good at shell script programming. However, the methods for solving problems vary, depending on the degree of professional knowledge, the types of commands used, and the way you view problems. For programmers at the initial stage of shell script programming, following approp
// displayed/
Iii. 'quotation marksThe function of anti-quotation marks is to replace commands and execute strings in the anti-quotation marks as commands. We often use shell programming to assign the execution result of system commands to a variable.
A = 'date'Echo $ A shows the time string instead of the date.For example, the content of file a is as follows:Abcdefg1234456Abcdefg
B = 'cat A | grep 234 '#
without variables are generally competent. However, when executing some decision-making tasks, it is necessary to include the IF/then condition judgment. Shell script programming supports such operations, including comparison operations and determining whether a file exists. The basic if condition Command Options include-eq-to compare whether two parameters are equal (for example, if [2-EQ 5]).-Ne-compare
= "color: #008080;" >6 else 7 echo num1 less than num2 " 8 fi 2) for statement1 # for in 'seq' #输出1 ~2for in 3456 4563 Do 4 Echo $i 5 Done 3) While statement1 while : 2 Do 3 Echo "Hello" 4 Done 5 4 ) until statement 6 until condition 7 Do 8 Command 9 Done 5. Shell functionsuch as the addition function:1 Add () {2 Echo '$:'$1', $:'$23Return $ (($1+$2))4 }5Add3 46 Echo "The sum is: $?"A few special characte
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.