How to list text files without a .txt file extension?

To match files that do not have an extension at all, you can use the command

ls | grep -v '\.'

To match files that do not have a .txt extension, you can use the command

ls | grep -v '\.txt'

This will pass the list of files in the current directory to grep, which will remove all file names that have a . (or .txt for the second command) in them.


With ls -ignore="PATTERN" you can exclude files from a ls result.

For example, ls --ignore="*.txt" to ignore txt files.


Simply negate your pattern (note: shopt -s extglob is required).

To display all files without extension:

ls !(*.*)

To show non-txt files, try:

ls !(*.txt)