Bash: find -exec and file names

I want to remove HTML from several hundred files.

Here is the command I started with:

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

The problem I am facing is that she created one large .htm.out file (named {} .html.out) - I want the file I use to be named regardless of its original .out.

For example, I have

 2002/filename.html 

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

Any suggestions? I am open to other solutions that do not use bash

I am using cygwin.

+6
source share
1 answer

Redirection occurs outside of find . Call the subshell.

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

Source: https://habr.com/ru/post/886828/


All Articles