如何从链接列表中并行卷曲

时间:2018-07-14 22:27:51

标签: bash curl parallel-processing sh gnu-parallel

list.txt包含链接。我需要同时卷曲它们。意味着同时卷曲example.comabc.com123.com

我尝试过的

mycurl() {
curl $1
}
seq 1 | parallel -j0 mycurl list.txt >> output.txt
#I've also tried
seq 1 | parallel -j0 mycurl ::: list.txt >> output.txt
#I"ve also tried
parallel -a list.txt mycurl >> output.txt

它们都并行输出--help

list.txt内容

example.com
abc.com
def.com

1 个答案:

答案 0 :(得分:1)

我看不到您的mycurl()函数的要点,但是您可以按以下方式使用它:

# Declare 'mycurl()' function
mycurl() {
   # list.txt can be accessed in here if you want
   curl $1
}

# Make 'mycurl()' function available to processes started by 'parallel'
export -f mycurl

# Call 'mycurl()' once with each line of 'list.txt' as parameter
parallel -a list.txt mycurl {} > output.txt