提问人:cssjs 提问时间:7/12/2023 最后编辑:Nic3500cssjs 更新时间:7/13/2023 访问量:42
在BASH中,如何查找没有file.extension的文件
in BASH, how to find files with no file.extension
问:
echo >tst
echo >tst.
echo >tst.txt
echo >tst.html
echo >tst.ms.html
echo >tst.ms..html
find -maxdepth 1 -type f -name "*."
我只得到: ./tst。
我想得到一个文件 ./tst sans 尾随点
答:
-1赞
nish-ant
7/12/2023
#1
在这种情况下,一种解决方案是用于排除名称中包含任何句点的所有名称:!
find ./ -maxdepth 1 -type f ! -name "*.*"
它只返回 ../tst
评论
0赞
larsks
7/12/2023
这个答案看起来很奇怪地熟悉......几乎就像其他人发布了同样的东西一样。
0赞
nish-ant
7/12/2023
奇怪的是,回答一个没有回应的问题需要一分多钟,当你点击提交时,你会看到 1 分钟前对问题的评论
0赞
larsks
7/12/2023
是的,这就是网站的本质。
0赞
Diego Torres Milano
7/13/2023
#2
仅使用bash
shopt -s extglob
echo !(*.*)
不过,它不会排除目录
评论
find . -type f \! -name '*.*'
.