How to list text files without a .txt file extension?
Solution 1:
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.
Solution 2:
With ls -ignore="PATTERN"
you can exclude files from a ls result.
For example, ls --ignore="*.txt"
to ignore txt files.