Command: find files without extension

ayok13 -  
dna.factory Posted messages 19870 Registration date   Status Modérateur Last intervention   -
Hello,

I want to specify that I am in a Cygwin console, but I don't think that changes much. I am in a directory with a lot of files. I need to work on files that have no extension.
I would like to know the command that allows me to list these files. Whether it is with "ls", "find", or whatever, as long as it displays the list of these particular files.
Thank you very much ;)

Configuration: Windows 7 / Firefox 12.0

3 réponses

dna.factory Posted messages 19870 Registration date   Status Modérateur Last intervention   1 621
 
who don't have a point, or no extension?
a simple grep -v . will show you all the files without dots.
a grep -v '\....$' should (if I'm not mistaken about regular expressions) show you all the files except those ending with a dot followed by 3 characters.
(the command contains 4 consecutive dots)
you can extend the regex to search for 2 to 4 characters after the dot. *
(or be lazy and pipe 3 grep -v)
google-chance: grep+regex : http://www.robelle.com/smugbook/regexpr.html
Stop failing the Turing test!
0
dubcek Posted messages 18814 Registration date   Status Contributeur Last intervention   5 655
 
hello
search all files whose name does not end with . and 3 characters
find . ! -iname "*.???"
0
ayok13
 
Thank you very much for your responses, quick as well :D
The files have no dot and no extension, a real Linux file ;)
@dna.factory: I couldn't achieve my goal with grep.
"grep -v ." gives me nothing, the prompt disappears and seems to be waiting.
When I prepend it with a ls, it still gives nothing.
For the regular expression, when I run grep by itself it does the same as the first time and waits. When I pipe it to ls it does indeed show some files without extensions (but not all, I checked by looking manually at the long list of files in the directory), but also some .exe files..., strange.
But I think that indeed with regular expressions we should be able to do it, and it's true that with the one you suggested it should have worked, weird...
@dubcek: the command works great. To generalize the command we can even use "*.*"
Thanks again.
0
dubcek Posted messages 18814 Registration date   Status Contributeur Last intervention   5 655
 
file names can contain periods without representing an extension: a.b.c, xxxx-1.2
0
dna.factory Posted messages 19870 Registration date   Status Modérateur Last intervention   1 621
 
I may have been terse...
grep -v on its own won't give you anything; you need to use it as a filter for another command, like ls.
ls | grep -v tmp will output all file names that do not contain tmp (whether at the beginning, in the middle, or at the end)
ls | grep -v '\.tmp$' will list all files that do not end with .tmp
ls | grep -v '\..\{2-4\}$' should (I can't guarantee anything, and I'm on vacation, so I don't have my sco, my cygwin, or my debian with me to validate) list all files that do not end with a dot followed by 2 to 4 characters (from .7z to .html).

The advantage of grep is that you can use it in conjunction with find, which is much more powerful (size, modification date, etc.) than ls.
Since regex are what they are, you should be able to use them with find as well.
0