shell-加载文件内容到数组

准备工作

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

演示

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

输出结果为:

posted @ 2020-06-05 00:30  徐野子  阅读(585)  评论(0编辑  收藏  举报