『壹』 linux shell 文本文件逐行讀取到一個數組,這個怎麼寫
就你這么寫就行啊,循環中加一條++k
『貳』 linux shell 使用數組拷貝文件
#!/bin/bash
sdir=/home/flycat
pdir=/tmp/test
array=(`ls -l $sdir | grep ^- | awk '{print $8}'`)
for i in ${array[*]};do
cp $sdir/$i $pdir
done
『叄』 shell 讀取文件內容定義數組求教。
行處理用while read, 數組用 read -a :
#!/bin/bash
while read -a ARRAY
do
echo ${ARRAY[@]}
done < test
復制代碼