让 7zip 接受管道参数
我正在将文件列表传输到 7zip,尽管它对 cat 这样的东西运行良好,但它似乎并不喜欢这样。
find . -type f | grep -E '\.rar' | 7z -o/unrar/ #fails
Error:
Incorrect command line
find . -type f | grep -E '\.rar' | cat
//fullpath/file1.rar
//fullpath/file2.rar
//fullpath/file3.rar
我从 cat 中看到了第一个返回,并将其正常传递给 7zip,正如我所期望的那样。这工作得很好
7z -o/unrar //fullpath/file1.rar
也许我应该放弃并只使用 tar ?我更喜欢 7zip 的 API。
I'm piping a list of files to 7zip, it does not seem to like this despite it working fine to something like cat.
find . -type f | grep -E '\.rar' | 7z -o/unrar/ #fails
Error:
Incorrect command line
find . -type f | grep -E '\.rar' | cat
//fullpath/file1.rar
//fullpath/file2.rar
//fullpath/file3.rar
I took the first return as you see it from cat and passed it normally to 7zip as I expect that pipe does. This worked fine
7z -o/unrar //fullpath/file1.rar
Maybe I should give up and just use tar? I like the API for 7zip a little better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您期望 7z 从标准输入而不是命令行读取要处理的文件名?您确定您的意思不是
这样的吗?
它将找到所有也匹配 *.rar 的文件(类型 f)并在每个文件名上调用 7z。
You're expecting 7z to read the filenames to treat from standard input, not the command line? Are you sure you don't mean
or something like
which will find all files (type f) that also match *.rar and call 7z on every filename.