bash - 如何在bash中将数字序列重定向到并行
问题描述
我想并行化 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
我尝试使用 < `seq 1 100` 但这也没有用。有谁知道我怎么能绕过这个?
解决方案
对 OP 当前代码的小调整:
# as a pseduto file descriptor
parallel -j10 brx < <(seq 1 100)
或者:
# as a 'here' string
parallel -j10 brx <<< $(seq 1 100)
推荐阅读
- r - 在堆叠的ggplot geom_bar中添加不同颜色的数据标签
- python - 美丽汤。一个链接的搜索优化
- javascript - Javascript文件未加载
- google-chrome-extension - Chrome 扩展程序发布延迟
- java - 在spring webflow中将我的应用程序的http请求重定向到外部网站
- excel - 在循环中只发送一条带有 HTML 代码的消息
- python - 如何从json单行字典中获取字典
- database - 截断特定数据库中的表
- android - 使用 IntentService 进行依赖注入不起作用
- python - Seaborn Lineplot 错误地尝试对我已经排序的数据进行排序