庆典:找到-exec和文件名 [英] bash: find -exec and filenames

查看:169
本文介绍了庆典:找到-exec和文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要剥离HTML出几百个文件。

I want to strip the HTML out of few hundred files.

下面是我启动的命令:

find -name *.html -exec w3m {} > w3m {}.html.out \; 

我碰到的问题是,它创造了一个单一的大.htm.out文件(名为{} .html.out) - 我想我使用被命名的文件不管它原来是.OUT

The problem I've run into is that it created one single large .htm.out file (named {}.html.out) -- I want the file I'm using to be named whatever it's original is .out.

比如说,我有

2002/filename.html

我想通过w3m的运行它,并获得2002 / filename.html.out

I want to run it through w3m, and get 2002/filename.html.out

有什么建议?我接受不使用bash其他解决方案

Any suggestions? I'm open to other solutions that don't use bash

我使用Cygwin的。

I'm using cygwin.

推荐答案

重定向发生之外找到。调用子shell。

The redirection happens outside of find. Invoke a subshell.

find -name *.html -exec bash -c 'w3m "$1" > w3m-"$1".html.out' w3mout {} \; 

这篇关于庆典:找到-exec和文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆