gpt4 book ai didi

Linux : Remove/Delete . txt 文件以恰好五位数字结尾

转载 作者:太空宇宙 更新时间:2023-11-04 04:41:13 24 4
gpt4 key购买 nike

  • 顺便说一句,此命令适用于 me- rm {path}/*[0-9][0-9][0-9][0-9][0-9].txt

  • 有没有更短的方法?因为根据需要我们可以将其扩展到删除所有以 10 位数字结尾的 .txt 文件。

--我们需要删除名称为 abc12345、ac12456、abcd98653 等的文件..

最佳答案

此命令在 Linux 中查找 rm 的文件名模式为 [任意位数].txt 的文件:

find /path/to/search -type f -regextype posix-extended -regex '^.*/[0-9]+\.txt' -exec rm -f {} \;

这个 rm 的文件正好有 10 位数字。

find /path/to/search -type f -regextype posix-extended -regex '^.*/[0-9]{10}\.txt' -exec rm -f {} \;

尝试不使用“-exec rm -f {}\;”首先查看它是否与要删除的正确文件匹配

关于Linux : Remove/Delete . txt 文件以恰好五位数字结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27694644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com