当前位置: 首页 > news >正文

[Unix Pipe] find . -maxdepth 1 -type f -name *.torrent | transmission-show

 

 find .  -maxdepth 1  -type f  -name "*.torrent" | transmission-show
tell me how to write this pipe correctly.

 

 

The reason your current pipe isn't working is that transmission-show expects a file path as an argument, but a pipe (|) sends the text (the filenames) to the program's standard input (stdin).

To bridge this gap, you need a tool that converts those lines of text into actual command arguments.


Solution 1: Using xargs (Recommended)

This is the most common way to handle this. xargs takes the output from find and passes it as arguments to transmission-show.

Bash
 
find . -maxdepth 1 -type f -name "*.torrent" | xargs -I {} transmission-show "{}"
  • -I {}: This tells xargs to use {} as a placeholder for the filename.

  • "{}": Quoting the placeholder ensures that filenames with spaces don't break the command.

Solution 2: Using find -exec (Cleaner)

You actually don't need a pipe at all. The find command has a built-in feature to run commands on every file it discovers.

Bash
 
find . -maxdepth 1 -type f -name "*.torrent" -exec transmission-show {} \;
  • -exec ... {}: Runs the command for every match.

  • \;: This tells find where the command ends.

Solution 3: The "Modern" Way (GNU Parallel)

If you have a massive list of files and want to see the output faster, you can run them in parallel:

Bash
 
find . -maxdepth 1 -type f -name "*.torrent" | parallel transmission-show

Which one should you use?

Method Best For...
xargs Standard piping workflows and complex tool chains.
-exec Simplicity; it's self-contained within the find command.
parallel Processing hundreds of files simultaneously.

Pro Tip: If your filenames have weird characters or newlines, use find . -print0 | xargs -0 to ensure the shell doesn't get confused by the formatting.

Would you like me to show you how to redirect all that output into a single text file for easier reading?

 

Since transmission-show outputs a lot of metadata for every single file (trackers, file lists, piece hashes), running it on a batch of files will likely flood your terminal.

Redirecting the output to a file allows you to search through it later or keep a log of your torrent data.


1. The Simple Redirect

This will create a file named torrents_info.txt containing the output for every file found.

Bash
 
find . -maxdepth 1 -type f -name "*.torrent" -exec transmission-show {} \; > torrents_info.txt
  • >: This creates (or overwrites) the file.

  • >>: Use this instead if you want to append to an existing file without deleting its current contents.

2. Including the Filename

By default, transmission-show displays internal torrent info, but it might not clearly label which file it's looking at in the text log. You can force it to print the filename first:

Bash
 
find . -maxdepth 1 -type f -name "*.torrent" -exec echo "FILE: {}" \; -exec transmission-show {} \; > torrents_info.txt

3. The "See it and Save it" Method (tee)

If you want to watch the output scroll by in your terminal and save it to a file at the same time, use the tee command:

Bash
 
find . -maxdepth 1 -type f -name "*.torrent" -exec transmission-show {} \; | tee torrents_info.txt

Summary of Redirection Symbols

Symbol Action
> Write output to a file (overwrite existing).
>> Append output to the end of a file.
2> Redirect only errors to a file.
` tee`

Would you like me to help you write a script that filters for specific info—like just the Magnet Links or Trackers—from those files?

 

 

 

http://www.jsqmd.com/news/328040/

相关文章:

  • 2026年青少年内衣权威企业盘点:科技健康引领新选择
  • 十六、用 GPT2 中文古文模型实现经典名句续写
  • 十四、基于 BERT 的微博评论情感分析模型训练实践
  • 260131 今年已经过去一个月了
  • 大数据领域 HDFS 的数据一致性保障
  • 探索大数据领域 RabbitMQ 的多租户模式
  • 大数据领域数据架构的财务管理应用
  • 腾讯超算中心AI资源调度:架构师如何支持游戏AI应用?
  • 基于SpringBoot+Vue的房屋交易平台管理系统设计与实现【Java+MySQL+MyBatis完整源码】
  • Java Web 经方药食两用服务平台系统源码-SpringBoot2+Vue3+MyBatis-Plus+MySQL8.0【含文档】
  • SpringBoot+Vue Spring Boot疗养院管理系统平台完整项目源码+SQL脚本+接口文档【Java Web毕设】
  • Spring Boot企业员工薪酬关系系统信息管理系统源码-SpringBoot后端+Vue前端+MySQL【可直接运行】
  • Java SpringBoot+Vue3+MyBatis 高校教师电子名片系统系统源码|前后端分离+MySQL数据库
  • hendon test routers
  • 2601C++,复制超文本格式
  • 2601,写个kde语法高亮文件
  • 2026年SPC蜂窝铝整板生产商深度评测:谁才是性价比之王?
  • 驻马店全铝焊接大板企业如何选?2026年开年深度观察
  • 驻马店全铝阳台柜选购指南:2026年头部厂商深度解析与推荐
  • 算法题-03
  • OTG数据充电交互讲解
  • LDR系列PD应用方案讲解之OTG边听边充边传数据边投屏多合一应用
  • Type-c OTG数据与充电如何进行交互使用应用讲解
  • 大规模语言模型的反事实推理在政策模拟与评估中的多维度应用
  • Issacsim探索——Day1-云服务器一键启动
  • Java语言提供了八种基本类型【函数红色的1】
  • Java全栈开发工程师面试实录:从基础到高阶技术深度解析
  • 2026年武汉市政工程施工服务商价格解析与优质厂商推荐
  • 超越加速:AI编程如何成为开发者能力的“无限杠杆”?
  • 寻找差异表达基因,进行富集分析