Skip to content

Array in Bash

变量

$VAR
或者
${VAR}

数组

${VAR[$i]}

打印整个数组

echo ${VAR[@]}

统计数组元素个数

echo ${#VAR[@]}

从文件读入数组

(按行读入)

VAR=(`cat 'eg.txt'`)

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback me#imzye.me, replace # with @
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Try iOS App