shell-加载文件内容到数组

准备工作

首先准备一个文本文件test.txt

演示

#!/bin/bash
x=(`cat test.txt`)
for i in ${x[@]}
do
        echo $i
done

输出结果为:

原文地址:https://www.cnblogs.com/hxlinux/p/13047422.html