bash: find -exec and filenames

自古美人都是妖i 提交于 2019-11-28 07:39:19

问题


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

Here's the command I've started with:

find -name *.html -exec w3m {} > w3m {}.html.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.

For instance, I have

2002/filename.html

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

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

I'm using cygwin.


回答1:


The redirection happens outside of find. Invoke a subshell.

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


来源:https://stackoverflow.com/questions/5810296/bash-find-exec-and-filenames

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!