我尝试查找没有点符号的文件夹。我通过以下脚本在用户目录中搜索它:
!#/bin/bash
users=$(ls /home)
for user in $users;
do
find /home/$user/web/ -maxdepth 1 -type d -iname '*' ! -iname "*.*"
done
Run Code Online (Sandbox Code Playgroud)
但我在结果中看到用户的文件夹带有点,例如 - test.uk 或 test.cf
我做错了什么?
提前致谢!
您可以使用findwith-regex选项:
find /home/$user/web/ -maxdepth 1 -type d -regex '\./[^.]*$'
Run Code Online (Sandbox Code Playgroud)
'\./[^.]*$'将匹配不带任何点的名称。