这是我脚本的一部分:
num=`wc -l /tmp/list.txt | awk '{sum += $1} END {print sum}'`
for i in $(seq $num)
do
touch /tmp/pages/$i.txt
done
#OR:
#awk '{system("touch /tmp/pages/"NR".txt")}' /tmp/list.txt
i=1
for line in $(cat list.txt)
do
#for (( i = 1; i <= num; i++ ))
#do
wget $line --no-check-certificate -O /tmp/pages/$i.txt
i= i+1
#done
done
如何将list.txt
中每一行的输出分配给我的i
变量?
例如:
line one > 1.txt
line two > 2.txt
等等......
答案 0 :(得分:3)
使用awk
:
awk '{print > NR".txt"}' list.txt
答案 1 :(得分:2)
i=1
while read line
do
echo "$line" > /tmp/pages/$i.txt
let i=i+1
done < list.txt