in BASH, how to find files with no file.extension

47 Views Asked by At
echo >tst
echo >tst.
echo >tst.txt
echo >tst.html
echo >tst.ms.html
echo >tst.ms..html

find -maxdepth 1  -type f -name "*."

I get only: ./tst.

I want to get the one file ./tst sans trailing dot

2

There are 2 best solutions below

3
nish-ant On

One solution in this case is use ! to exclude all the names with any period in their names:

find ./ -maxdepth 1 -type f ! -name "*.*"

which returns only ./tst.

0
Diego Torres Milano On

Using only bash

shopt -s extglob
echo !(*.*)

it won't exclude dirs though