bash - 如何在 bash/shell 脚本中查找不以 ".log"结尾的文件

标签 bash shell unix find

我是 bash/shell 脚本的新手。 我想找到目录和子目录中所有不以“.log”结尾的文件。 我知道我可以使用下面的命令来获取以“.log”结尾的文件,但我需要那些不以这个扩展名结尾的文件:

find /tmp/mallik5/ -iname "*.log"

我该怎么做?

最佳答案

这个find表达式可以做到:

find /tmp/mallik5/ ! -name "*.log"

如果只是查找文件,添加-type f:

find /tmp/mallik5/ -type f ! -name "*.log"

关于bash - 如何在 bash/shell 脚本中查找不以 ".log"结尾的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19164196/

相关文章:

linux - 如何直接在终端中更改屏幕单元格的颜色?

windows - 如何让 grep 忽略 Windows 换行符?

linux - 远程 SSH 命令在 Linux 中不起作用

linux - Shell 脚本 - 如何根据输入模拟某些结果?

linux - 从 shell 脚本中的变量运行 shell 命令

python 守护进程 - 为什么这个函数会杀死父进程两次?

linux - 在 shell 脚本中使用查找

python - 如何传递 docopt 参数,其中参数是 python 中带空格的字符串

c++ - 自旋锁与信号量

c++ - 使用套接字跟踪 HTTP 响应 header