如何在bash中将数字序列重定向到并行

ken*_*e41 3 bash gnu-parallel

我想并行化 curl 请求,我在这里使用了代码。我想使用的输入是使用生成的一系列数字,seq但重定向不断给我错误,比如输入不明确。

这是代码:

#! /bin/bash

brx() {
  num="$1"
  curl -s "https://www.example.com/$num"
}
export -f brx

while true; do
  parallel -j10 brx < $(seq 1 100)
done
Run Code Online (Sandbox Code Playgroud)

我尝试使用 < `seq 1 100` 但这也不起作用。有谁知道我怎么能解决这个问题?

mar*_*rkp 5

对 OP 当前代码的小调整:

# as a pseduto file descriptor

parallel -j10 brx < <(seq 1 100)
Run Code Online (Sandbox Code Playgroud)

或者:

# as a 'here' string

parallel -j10 brx <<< $(seq 1 100)
Run Code Online (Sandbox Code Playgroud)