" | | (The echo '/etc/hosts file does not exist. '; exit 1) If ["$?"-eq 1]; Thenexitfiecho '/etc/hosts file exists, subsequent processing continues ... 'Line 3, use-E to determine whether/etc/hosts this file exists, if it does not exist, then () open a word shell, display the file does not exist information, and then return the left State value 1.Line 4, if leave status is 1, end script.2. Conditional judgm
a blog distinguishes the state return value in the shell -return-break-continue-exitFirst, The difference and contrast between break, continue, exit, return Condition and loop control and program return value command Knowledge table
Command
Description
break n
n , the jump out of the loop ,n
Analysis: Randomly generate 10 numbers? Generate a random number, here with the random function, I define the generated 10 numbers as an array of arrays, the initial value of the definition max is array[0] use for loop to compare with each element's value, if there is greater than array[0], if ARRAY[3] Larger than array[0], then assign the value of Array[3] to Ma
1. When a shell script executes a Python script, it needs to use the return value of the Python script to determine the command to be executed by the subsequent program.Example: There are two py programs hello.pyCopy CodeThe code is as follows:def main ():Print "Hello"If __name__== ' __main__ ':Main ()world.pydef main ():Print "Hello"If __name__== ' __main__ ':Main ()Sh
[Seemingly challenging] How does shell obtain the return value in php? for example, the php file returns an array nbsp; PHPcode lt ;? Phpreturnarray (a gt; 1, B gt; 2, c gt; public, d gt;, e gt ;,); [seemingly challenging] How does shell obtain the return value in php?
The php file returns an array.
PHP cod
A comparison of the numerical values
Describe
N1–eq N2
As
N1–GT N2
Greater than
N1–ge N2
Much more than
N1–lt N2
Less than
N1–le N2
As small as
N1–ne N2
Not equal to
string comparison
Describe
STR1 = str2
As
Str1! = str2
Not equal to
STR1
Less than (must be used by definition)
1. PrefaceAlmost half a year did not write a blog, wasted a long time, work in the chores too much, their own more and more lazy. In order to spur their own growth, or to insist on writing a blog, record their growth.2. Shell Function Introduction Grammar:function ] funname [()]{ action; [return int;] }Description(1) can be defined with function fun () or directly fun (), without any parameters.(2) The parameter returns, can display plus: return
Tags: hash macbook hash newline character MacOS ADC method Roo md5sumtoday, I have no intention of discovering that computing MD5 hashes on Linux is not the same as in MacOS:Linux[[email protected] ~]# echo ‘123456‘ | md5sum f447b20a7fcbf53a5d5be013ea0b15af -Mac[[email protected] Notes]$md5 -s 123456 MD5 ("123456") = e10adc3949ba59abbe56e057f20f883eCareful toss, the original is the echo output string will be added by default a newline character '
$1>a[2]?$1=$1-a[2]:$1=a[2]-$1----> 545 greater than 8, so perform 553-8=545$2>a[2]?$2=$2-a[2]:$2=a[2]-$2----> 556 greater than 8, so perform 556-8=548$3>A[2]?$3=$3-A[2]:$3=A[2]-$3----> 32 greater than 8, so perform 32-8=24$4>a[2]?$4=$4-a[2]:$4=a[2]-$4----> 21 greater than 8, so perform 21-8=13Last process third row$1>a[3]?$1=$1-a[3]:$1=a[3]-$1----> 1 less than 2, so perform 2-1=1$2>a[3]?$2=$2-a[3]:$2=a[3]-$2----> 1 less than 2, so perform 2-1=1$3>a[3]?$3=$3-a[3]:$3=a[3]-$3----> 14 greater than 2
Today, writing scripts, encountering awk script to the shell of the case, the internet Google, found that there are some problems, through the pipeline, through Eval, feeling is very complex. So I thought to try it with read.First, a test file Test.txt is constructed, and the contents are 1 2 3.First try' {print $ $} ' test.txt | Read a b CBut echo $a, found to be empty, failed.Try it." 1 2 3 " | Read a b CYou can't assign a b c to a value.It seems th
"Seemingly challenging" how the shell gets the value of return in PHP
Title PHP This file is to return an array
PHP Code
' 1 ', ' b ' = ' 2 ', ' c ' = ' public ', ' d ' = ' ', ' e ' = = ', '; >
In the shell how to receive this array ah or there is no way
------Solution--------------------
PHP Code
[User:root time:07:23:08 path:
Background: defines a function that is different than the number of local and online server clusters, and wants to get the number of distinct clusters. The function return value of the shell and other languages is quite different. Define a functionfunctionname () {Action Contentecho Output Contentreturn value #返回值可有可不有}get the return
Tag: Shell finds the maximum value in an array elementHow does the shell compare the maximum values in all the elements in an array? Such as:array= (111 222 333 444 555 999 888 777 666) How to find the biggest element 999?Idea: Set a value max=${array[0]} that is the first element of the array, then use a For loop, tak
Use of the special variable IFS in shell, and the difference between the value of $ '\ n' and' \ n', shellifs
When a for loop is used in shell, the IFS is also used to define the separator. To specify multiple IFS characters, you only need to concatenate them in the value assignment line. As follows:
IFS = $ '\ N ':;
#!/bin/bash- function mytest () { echo "arg1 = $" If [$ = "1"]; then return 1 else return 0
fi}if MyTest 2; Then echo "Aaaaaaaaaa" fi
Execution Result:Change it a little bit.#!/bin/bash-function mytest (){echo "Arg1 = $"if [$ = "1"]; thenReturn 1Elsereturn 0Fi}If mytest 1; Thenecho "AAAAAAAAAA"Fi---------------------------------------------------------------------------The variables defined in the shell are
:$ md5sum-c LINUXMINT-12-GNOME-DVD-32BIT.MD5Output if the checksum is correct:Linuxmint-12-gnome-dvd-32bit.iso: OKIf the checksum error is output:Linuxmint-12-gnome-dvd-32bit.iso: Failed md5sum: Warning: 1/1 generated checksum mismatch command interpretation: md5-c: Read MD5 checksum from file and checkMessage Digest algorithm MD5 is a hash function widely used in the field of computer security to provide integrity protection for messages. The algorithm's file number is RFC 1321 (R.rivest,mit La
Test 101-le 99101 is less than or equal to 99Similar special symbols are also available.-eq "Judgment is equal"-ge "judgment is greater than or equal to"-lt "judgment is less than"-ne "judgment is not equal to"You can use the command "[]" instead of the test command as a logical expression#! /bin/bashecho if 101 smaller than 100if test 101-le 100then echo trueelse echo Falsefiecho if 101 bigger than 100 If [101-gt]then echo trueelse echo Falsefi 1 [[email protected]
There are n kinds of methods, awk, sad, grep, cut ...The above several ways do not write, just write two less commonly used to.Say less nonsense, directly on the code:Cat a.txt aa.gif=aaaa.gifbb.gif=bbbb.gifcc. gif=cccc.gifMethod One:#!/bin/sh while read line do k=${line%=*} v=${line#*=} Echo " $k: $v"done Operation Result:aa.gif: aaaa.gifbb.gif: bbbb.gifcc. gif: cccc.gifMethod Two:#!/bin/shIFS='=' while read K v do echo"$k : $v" Done View CodeOperation Result:aa.gif
#!/bin/bash#Remove the mer.*_ in file name is all of the files in a dirfunctionGetdir () { forElementinch' ls $` DoDir_or_file= $"/"$element if[-D$dir _or_file] then Getdir$dir _or_file Else #deal with all file in DirMv$dir _or_file' Echo$dir _or_file|sed ' s/mer.*) _//G ' fi done}#Check the input argsif(($#ThenEcho"Please input the dir of calibration images"Exitfiroot_dir= $Getdir$root _dir#Create the dir name using TimestrResult_dir="./result_of_"$ (Date +%y:%m:%d-%h:%
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.