【问题标题】:bash: find -exec and filenamesbash:查找 -exec 和文件名
【发布时间】:2011-08-14 04:41:57
【问题描述】:

我想从几百个文件中删除 HTML。

这是我开始使用的命令:

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

我遇到的问题是它创建了一个大的 .htm.out 文件(名为 {}.html.out)——我希望我使用的文件被命名为原始文件是 .out .

例如,我有

2002/filename.html

我想通过w3m运行,得到2002/filename.html.out

有什么建议吗?我对其他不使用 bash 的解决方案持开放态度

我正在使用 cygwin。

【问题讨论】:

    标签: bash find exec w3m


    【解决方案1】:

    重定向发生在find 之外。调用子shell。

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

    【讨论】:

    • 让它与这个命令一起工作:find -name *.html -exec bash -c 'w3m "$1" > "$1".html.out' w3mout {} \;
    猜你喜欢
    • 2015-05-09
    • 1970-01-01
    • 2018-04-08
    • 2018-01-21
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-07
    相关资源
    最近更新 更多