Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: October 29, 2025
File management is one of the core aspects of Linux systems that involves the creation, organization, storage, retrieval, and maintenance of files and directories. There are various scenarios when we may need to find specific files. In these situations, Linux provides powerful and versatile commands to efficiently search through file systems.
In this tutorial, we’ll learn how to find files without an extension.
The code in this tutorial underwent testing on a Debian 12 (Bookworm) system using GNU Bash 5.1.16.
First, let’s ensure we have all the prerequisites ready, including files without an extension.
$ mkdir dir1 && touch dir1/{file1,file2.txt,file3,file4.csv,file5}
The mkdir command creates a directory dir1, while the touch command uses brace expansion to create five empty files within that directory.
Similarly, let’s create a subdirectory with a few files within the dir1 directory to check the depth of the commands used in this tutorial.
$ mkdir dir1/subdir1 && touch dir1/subdir1/{subfile1.csv,subfile2,subfile3.txt,subfile4}
This command creates a directory named subdir1 within the dir1 directory with four empty files.
A filename generally consists of a basename and a file extension, separated by a dot. For example, in the filename document.txt, document is the basename and txt is the file extension. To find a file without an extension, we can search for the files without a dot in their name. Certain files may have dots in their name and still lack an extension, such as .gitignore or my.file.dot.here, but we will not cover such filenames in this tutorial.
We can find the files without an extension in a given directory using find, locate, and with the combination of ls and grep.
The find command provides several options for finding files and directories on a disk recursively. We can use the -name option to search for files without an extension:
$ find dir1/ -type f ! -name '*.*'
dir1/file1
dir1/subdir1/subfile2
dir1/subdir1/subfile4
dir1/file5
dir1/file3
This command finds all the files within the dir1/ directory that don’t have a dot in their name, i.e., files without an extension.
The find dir1/ construct searches for files within the dir1/ directory, having properties defined by the following parameters:
Thus, the ! -name ‘*.*’ construct finds files without a dot in their name.
Additionally, we can also use regular expressions to specify the filename pattern with the -regex option:
$ find dir1/ -type f -regex '^[^.]*$'
This command uses a regular expression pattern to match filenames without a dot in their name, i.e., files without an extension.
We can use the locate command to find the location of files that match specific criteria in a database generated by updatedb.
Before we dive into the details, let’s verify that we have the locate command installed on our system:
$ locate --version
plocate 1.1.15
Copyright 2020 Steinar H. Gunderson
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
In case it’s not already available, we can install the locate command from the local manager.
$ sudo apt install mlocate
Additionally, the locate command requires the database containing indexes of files and directories before it can be used. Let’s build the database using updatedb:
$ sudo updatedb
This command updates the database file with a snapshot of the file system.
The configuration file for updatedb, i.e., updatedb.conf, is generally stored in the /etc directory. This updatedb.conf file has several parameters like PRUNEPATHS, PRUNEFS, and PRUNENAMES. The paths included in PRUNEPATHS will not be scanned by the updatedb. Thus, we may need to check and update the /etc/updatedb.conf file if any path is not included in the search.
The updatedb command is typically scheduled to run daily by cron to update the index database. However, if files are modified, moved, or created after the scheduled update, the index database won’t reflect these changes. Thus, it is advisable to update the index database using updatedb immediately before the use of locate.
The locate command uses the index database to search for files and paths, resulting in the search of the entire system. Thus, it is faster than the recursive searching alternatives like find.
Let’s find the files without an extension using the locate command:
$ locate -w /home/user/Baeldung/dir1/ --regex '^.*/[^.]*$'
The above command searches for files and directories whose basename does not contain any dots.
The -w option searches the entire path name. The –regex option interprets the specified regular expression patterns, in this case, files without any dots in their names.
Furthermore, we can use the extended arguments (xargs) to filter out any directories from the output, keeping only regular files:
$ locate -w /home/user/Baeldung/dir1/ --regex '^.*/[^.]*$' | xargs -I {} bash -c 'test -f {} && echo {}'
/home/user/Baeldung/dir1/file1
/home/user/Baeldung/dir1/file3
/home/user/Baeldung/dir1/file5
/home/user/Baeldung/dir1/subdir1/subfile2
/home/user/Baeldung/dir1/subdir1/subfile4
This command outputs only the files without a dot in their name, i.e., files without an extension.
Let’s understand the new parameters used in this command:
Moreover, we can also limit the number of matches using the -l (–limit) option.
We can also find the files without an extension using the combination of ls and grep.
$ ls -RF dir1/ | grep -v "\."
In this command, we perform a recursive listing (-R) of the dir1/ directory and then use grep to filter the output, displaying only files and directories without a dot in their name.
Let’s break down this command to understand each option it employs:
The above command also lists the directories without a dot in their name. We can exclude directories from the output by adding one more pattern with the -e option:
$ ls -RF dir1/ | grep -v -e "\." -e "/$"
dir1/:
file1
file3
file5
dir1/subdir1:
subfile2
subfile4
This command outputs only the files without having a dot in their name from the specified directory, i.e., dir1/.
With the -e option, we can use regular expressions to match certain patterns. The -e “/$” matches the forward slash at the end of the line, filtering out the directories.
In this article, we have learned different ways to find files without an extension.
First, we discussed the recursive methods to search for files without extensions using find and the combination of ls and grep. Then, we practiced index-based searching with locate after creating the database with updatedb. locate leverages an index-based search, making it faster than the recursive methods.
Among these options, find is the simplest and most self-contained way to find files without an extension. Thus, it is the most recommended way to find files without an extension.