using []2. File test-e file: Test files exist-F File: Test files are normal files-D File: Test whether the files are directories-R File: Tests whether the current user has read access to the specified file-W File: Tests whether the current user has write access to the specified file-X file: Tests whether the current user has execute permissions on the specified filesuch as: if [-f/etc/inittab] (note space)Exit # define Exit status codeBash Variable typeLocal variable (local variable) "Scope is
$, backslash \, anti-quote ', exclamation point!. Anti-quote 'Two strings enclosed in anti-quotes, will run as commands,The output of the execution as the content of the anti-quote, called command substitution, It has another better way of writing: $ (command) TAR-ZCVF lastmod.tar.gz ' Find. -mtime-1-type F-print ' 4. If control statementIf [...] Then ... Elif ... then. ... Else ... Fi Use "[]" to represent the condition test. Note that the space here is very important! The space to ensure the
Date: September 13, 2015Case statementCase statement: The statement and if are not much different, the main purpose is to make the logical structure of the code clearer.A case statement can be referred to as: A concise version of a multi-branch if statementUsage scenario: Determining if a variable's value is one of several scenariosThe case statement uses the following format:Case $VARIALBE inPATTERN1)Branch 1;; errorPATTERN2)Branch 2;; errorPATTERN3)Branch 3;; error...*)Branch N;; errorEsac
Bash Script Programming:Programming Languages:Sequential executionSelect ExecuteLoop executionSelect Execute:If judging conditionThenBranch code with true conditionFiif judgment condition; ThenBranch code with true conditionElseThe condition is a false branch codeFiWrite a shell if the user does not exist, add the user, and the existing information is printed.#!/bin/bashIf [$#-lt 1]; Thenecho "At least one"Exit 1FiIf ID $ >/dev/null; Thenecho "$ exixt
uncertain.However, the most important concept that this chapter will learn is not how to use the existing functional programming libraries, but how to use all the libraries that can enhance JavaScript functional programming. This chapter is not limited to one or two libraries and we will explore as many libraries as possible in order to examine the style of all JavaScript functional
divisible by 3;Modulus, residual:%3%2=1100%55=45Write a script:Calculates the sum of all odd numbers and all the even numbers within 100, and displays them respectively;Let i=$[$I +1]sum=$[$SUM + $I]let sum+= $Ilet i+=1 equivalent to let I++-=let i-=1 equivalent to let I--++i,--i*=/=%= Write a script that shows all the default shell-bash users and default shell-/sbin/nologin users on the current system, and counts the total number of users under eac
The Shell (Bash) programming instance obtains all the file names (including folders) in a folder. Many of them do not understand it, so they record all the files they actually use, I hope the experts will give you more valuable comments. Thank you www.2cto.com [plain] #! /Bin/sh #============= get the file name ============= Folder_A = "/home/youname/ shell/gotfilename/bin "for file_a in $ {Folder_A }/*; do
/*************************************** ******************************* 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
elements of the same data type arranged in a certain order, that is, a variable of the same type as a finite one.A name, followed by a number to differentiate their set of variables, called the array name, the number is called the array subscript.Each variable that makes up an array is called the component of an array, also known as an element of an array, sometimes called a subscript variable.Array definition:Method 1:array= (value1 value2 value3 ...)Method 2:array= ([1]=one [2]=two [3]=three]
$ echo the last argument is$$#The last argument is $4$ eval echo the last argument is$$#The last argument is D[Email protected]:~$ set-x//Open bash shell debug function[Email protected]:~$ eval echo the last argument is $$#+ eval echo the last argument is ' $4 '+ + echo the last argument is DThe last argument is DIv. Exit commandThe exit command ends the script to return to the command line.The exit command can take a return value parameter, 0 means a
Label:Lvy Teacher Teaching Program, as well as a substitute shell part of the course, we all feel that the teacher does not work, the operation of the class is wrong, I think her foundation is not good. Moreover, she could not explain the reason, the student asked why, she did not know. Crash. To the XX training institutions after the reaction, said the teacher project experience, but if a person foundation is not, do more projects also no use Ah, all is wrong. This part has PDF, self-study. To
Article title: shell introduction to bash programming execution. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
There are five methods to execute a command in the Bourne Shell, and the results of these five methods are different:
: Run the following command directly:
Shell Script ProgrammingFgrep Fast grep quickly retrieves text but does not support regular-regular expressionsProgramming languages: Machine language, assembly language, advanced languages (compile required)Compiler or interpreter: is used to translate a language (usually a high-level language) that humans can recognize into a machine that can recognizeLanguage (i.e. machine language)Static language: Compiled language strongly typed (variable) keywords are fully converted into executable format
In bash script programming, it is easy to confuse and error in some places.
Today I came across an example, for example:
If ["$ uid"-ne "$ root_uid"]ThenEcho "must be root to run this script"Exit $ e_notrootFi
Just a few lines aboveCode, There are two errors.
1) there is no space between If and. Generate an error.2) There is no space between [and "," And], which leads to an error.
Maybe it's a habit
/%pattern}Five, character-case conversions:${var^^}: Converts all lowercase characters in var to uppercase;${var,}: Converts all uppercase characters in var to lowercase;Six, variable Assignment:${var:-value}: Returns value if the var variable is empty or not set, otherwise returns the var variable;${var:=value}: If the var variable is empty or not set, then return value and assign value to the var variable, otherwise return the value of the Var variable;${var:+value}: Returns VALUE if the var v
Index Ada Agda Alef Android APL Arduino asp net MVC Assembly Language non-x86 AutoHotkey autotools Awk Bash Basic BETA C C # C + + Chapel Cilk Clojure COBOL coffeescript ColdFusion Cool Coq D Dart DB2 delphi/pascal DTrace Elasticsearch Emacs Erlang F # Firefox OS Flex force.com Forth Fortran FreeBSD Git Go Groovy Gradle Grails Spock Framework graphical user interfaces Gr Aphics programming Hadoop Haskell
First, the function1, Function: Functions, functions2. function: To encapsulate a particular function or code that should be executed independently into a separate function and take a name, call it when used;3. function Features: Structured programming, can not be run independently, need to be executed when the call, may be called multiple times;Second, function programming and application1, define a functi
status
NBSP;
lock Type
advantages
cons
applicable range
biased lock
locking, unlocked unwanted amount External consumption
thread competition when there is additional lock cancellation consumption
Only one thread accesses the scene of the synchronization block
lightweight lock
competing threads do not block and incr
Bash programming arrays and string handlingDirectoryNote Date 20180405ArrayFame (Create) array declare-a array_nameAssignment of array elements array_name= ("VAL1" "VAL2" "VAL3" ...)Referencing an array element: ${array_name[index]}Bash's string processing toolString Slice ${var:offset:number}Pattern-based String ${var#*word}Find the value of the replacement variable ${var/pattern/match}Find and delete cert
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.