【问题标题】:How to remove only extension from origin file with certain extension recursively in folder?如何在文件夹中递归地从具有特定扩展名的原始文件中删除扩展名?
【发布时间】:2020-06-02 07:17:29
【问题描述】:

如何在文件夹中递归地从具有特定扩展名的原始文件中删除扩展名?

例如,如果我有

/foo/bar/index.html
/foo/bar/error.html
/foo/bar/static/hi.html
/foo/bar/static/me.jpg
/foo/bar/static/you.jpg
/foo/bar/build/yep.html

我希望在执行某些命令后会跟随

/foo/bar/index
/foo/bar/error
/foo/bar/static/hi
/foo/bar/static/me.jpg
/foo/bar/static/you.jpg
/foo/bar/build/yep

感谢您的帮助。 请告诉一些操作系统的命令如果命令存在(windows,ubuntu/linux)

【问题讨论】:

  • 欢迎来到 SO,在 SO 上,我们确实鼓励用户添加他们为解决自己的问题而付出的努力,所以请添加相同的内容并让我们知道。

标签: shell ubuntu command


【解决方案1】:

作为命令:

ls | find *.html | for f in *.html; do mv $f $(echo $f|sed s/.html//);done

【讨论】:

    猜你喜欢
    • 2012-11-29
    • 2020-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-27
    • 2011-08-21
    • 2015-02-01
    相关资源
    最近更新 更多