shell_Day08

And an array of strings:

Array

  Is a contiguous array of variables, a contiguous memory storage space
  to solve the problem of too many variables; variables in the same class, we do not need to define multiple names, but in an array of ways to define; (list)
  the array name [index] = value

Definition array

  declare -i integer defining (affirmed)
  DECLARE -a definition array Array
  DECLARE nested arrays defined -A

  array[8]=1
    In computer languages, typically the index count from zero
    index numbers are not necessarily
    the shell array assignment may jump (jump assignment)
  Array = (/ var / log / *. Log)
    made traverse
    Array = (ABCDE) 
  Array = ( 'a = 187' 'b = 186' ...)

Be assigned by the read command

  Delay read -t -p "Specify Description" -a variable desired value input array
  read -aabcde

Call Array

  $ {Variable name}
  $ {array name [index]} which index is defined, see corresponding index value specified
  $ {name} array called by default index = value of $ array 0 (best not to write)
  $ {array name [*]} or {$ array name [@]} for all calls within the array values $ * $ @
        

Call the array length of the array

  length ( "variable")
  $ {# variable name [*]} or {# $ variable name [@]}

Add special way an array of values

  $ {Variable name [$ {# variable name [@]}]} = "value" variable or $ {name [$ {# variable name [*]}]} = "value"
  
 

Other operations on the array

  Array slice
    $ {variable name [@]: Offset: the number of values that need to remove}
    echo $ {A [*]: 2:. 4}
    $ {variable name [@]: Offset} 
  delete values
    the unset $ {variable name [index]} 
  Note: delete the value of the index, without deleting the one with index;
  modified value of
    a [. 3] = C
    a [. 3] D = modified i.e. cover
 

String:


 python (% s,% d) % (name, hiaght)
  Output: aa, 1832
  S%
  % D
  % F
  
  % [NUM] Specifies the width of the string S placeholder
  % - [num] s behalf of Left

  

String sections:

  Slice Array: $ {variable name [@]: Offset: number of values}
  string: $ {variable name: Offset: number of values}
    $ {variable name: - the number of values} * Note: colon be sure to add a space behind *]
    $ {variable name: -word} default assignment means
    the Read "sasasa:" the Test
    [the -z $ the Test] && the Test = abc

Based on the mode takes a substring

  From right to left
    $ {variable name #pattern} delete pattern to the first match of the string
    $ {variable name ## pattern} to delete all the pattern matching string
  
  from right to left and from
    $ {variable name pattern}%
    $ { variable name %% pattern}

Character replacement

  $ {Variable name / pattern / replacement string} is not a regular expression pattern, but the wildcard file]
    match the first pattern, to replace
  {string variable name // pattern / replacement} $
    matches All Oh pattern, and replace
  $ {string variable name / # pattern / replacement}
    specify the match line must be first pattern, only replace
  {string variable name /% pattern /} $ replace the
    match-end of line must be a pattern, will be replaced
  Note: / separator, not replaced (#% other special characters, and sed not the same)

Find and delete

  Alternatively, the replacement string is not specified, i.e. delete
  $ {variable name / pattern}
  $ {variable name pattern} //
  $ {variable name / # pattern}
  $ {variable name /% pattern}

Replace case

  Alternatively case tr
  tr [[: lower:]] [[: upper:]] <filename
  $ {} String variable name ^^ replace all uppercase
  $ {} string variable name ,, replace all lowercase

Variable assignment

  1 variable name = $ {variable name 2: -word} There is no space! Enter a default value of the action, not the variable 2 values, default values will be assigned to a variable word 1
  variable name 1 = $ {variable name 2: + word} used without variable has a value of 2, the default value was assigned to the word 1 variable
  $ {variable: = word} If the variable has no value, will be assigned to a variable word, there is value, the original value of 
  the variable $ {variable 1 = 2:? error_infor} erro_infor error message if the variable value is not 2, the output

Two commands

  mktemp creates temporary files and directory temp - / tmp
  to avoid taking the name of the file repeat; mktemp name .XXXXXX (XX represents a random number (letters and numbers))
  is created by default is random file
    -d is randomly created directory
    file=`mktemp a.XXXX`
    install copy or delete files, use the same copy
  advantages can assign permissions to copy files
  Usage: intall a file directory // b b copy a file to a directory, and respond to initial permissions (file: 755 Contents: 644)
    -t source project on the exchange
    -d create
    -m the MODE
    -o OWNER
    -g the GROUP
 

Start principle of the system: virtualization ready knowledge

  Reading system - read the disk: the premise is that you must first load the driver disk
  to mount the virtual root (img virtual root file ramdisk)
  virtual root file later hung in grub1.5 load the disk drive;
  by chroot above the ramdisk the temporary "root" to switch to disk on top of
  the operating system: vmlinuz kernel, ramdisk.img
 
 

Guess you like

Origin www.cnblogs.com/diyudewudao/p/11408995.html