#数组的声明与遍历
Animals= ("A Dog" "A Cat" "A Fish")
#wrong ways
For i in ${animals[*]}; do echo $i; Done
For i in ${animals[@]}; do echo $i; Done
For i in "${animals[*]}"; do echo $i; Done
#this is what we want correct
For i in "${animals[@]}"; do echo $i; Done
#数组元素的排序
A= (F e d c b a)
echo "Original array: ${a[@]}"
A_sorted= ($ (For I in "${a[@]}"; does echo $i; done | sort))
echo "Sorted array: ${a_sorted[@]}"
#删除数组长或数组的某个元素
Foo= (a b c D E F)
Echo ${foo[@]}
Unset Foo[2]
Echo ${foo[@]}
The cut command cuts bytes, characters, and fields from each line of the file and writes those bytes, characters, and fields to standard output.
Main parameters
-B: Split in bytes. These byte locations will ignore multibyte character boundaries unless the-n flag is also specified.
-C: Split in characters.
-D: Custom delimiter, default is tab.
-F: Used with-D to specify which area to display.
-N: Cancels splitting multibyte characters. Used only with the-B flag. If the last byte of the character falls within the range of <br/> indicated by the List parameter of the-B flag, the character will be written out; otherwise, the character will be excluded.
#split string to array one demo
foo= "Hello world hello java hello docker hello spark Hello Stream"
Declare-a Bar
Read-a Bar <<< $foo
Linux Command ' s Array