shell 将文件内容读取到 数组中
#!/bin/bash
prod_file=/home/vmuser/linbo/kettleDemo/job/test/CA-20201224.csvtest_file=/home/vmuser/linbo/kettleDemo/job/test/uat_CA-20201224.csvdtm=`date +"%Y%m%d%H%M%S"`echo $dtmrowCnt=`cat $test_file | wc -l `echo $rowCntecho "---------------------------------------------------"# 设置IFS,将分隔符设置为换行符OLDIFS=$IFSIFS=$'\n'# 读取文件中的内容到数组中array=($(cat $test_file))# 恢复之前的设置IFS=$OLDIFSecho ${#array[*]}# 循环显示文件内容for v in {1..10}doecho " $v ==== ${array[v]} "done
浙公网安备 33010602011771号