我有一個.txt
文件,其中包含加載列表從文本文件bash腳本
abc.com
google.com
....
....
yahoo.com
而且我很感興趣,它加載到一個bash腳本的列表(即Domain_List=("abc.com" "google.com" .... "yahoo.com")
)。有可能嗎?
附加信息,一旦獲得列表,將用於for
循環和if
語句。
for i in "${Domain_list[@]}
do
if grep -q "${Domain_list[counter]}" domains.log
....
....
fi
....
let counter=counter+1
done
謝謝
更新: 我已經改變了格式DOMAIN_LIST =(「google.com ...... 「yahoo.com」),並使用source Doamin.txt
允許我使用Domain_list
作爲
#!/bin/bash
counter=0
source domain.txt
for i in "${domain_list[@]}"
do
echo "${domain_list[counter]}"
let counter=counter+1
done
echo "$counter"
你的問題已經回答了前: http://stackoverflow.com/questions/1688999/how-can-i-read-a-list-of-filenames-from-a-file -in-bash – Bill 2013-04-30 16:59:36