You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将基于seq的curl+xargs命令改为读取links.txt文件?

Modified Command for Your Use Case

Here's the adjusted command that replaces seq 1 10 with cat links.txt while keeping your parallel download behavior intact:

cat links.txt | xargs -n1 -I{} -P2 -- curl -O -s 'https://example.com/dir/{}.ts'

Key Adjustments Explained:

  • cat links.txt: Pulls your custom string list from the file instead of generating a numeric sequence.
  • -n1: Ensures xargs processes one string at a time. This is crucial if your strings are space-separated (like your example aada1 adk29 amn22), as it stops xargs from treating the entire line as a single argument.
  • -I{}: Still serves as the placeholder for each string, inserting it into the curl URL just like the numeric values in your original command.
  • -P2: Maintains the parallel download count at 2, matching your original setup.
  • The rest of the curl command stays the same, appending .ts to each string to form the full target URL.

Bonus Tip for Edge Cases:

If your links.txt has strings with spaces/special characters, or you want to strictly split entries by newlines (not spaces), add the -d'\n' flag to force line-based splitting:

cat links.txt | xargs -d'\n' -I{} -P2 -- curl -O -s 'https://example.com/dir/{}.ts'

内容的提问来源于stack exchange,提问作者JaneFarrow

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:14:36