Saturday, April 27, 2024
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 31243  / 2 Years ago, fri, april 8, 2022, 5:50:27

For example, how can I replicate:



ls *.txt


when my text files are missing the .txt ending, and as far as extensions go appear the same as many other types of file?



Alternatively, is it possible to list specifically just the files which have NO file extension?


More From » command-line

 Answers
5

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.


[#33074] Saturday, April 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
altybol

Total Points: 364
Total Questions: 138
Total Answers: 121

Location: France
Member since Thu, May 6, 2021
3 Years ago
altybol questions
;