Using ls, how to list files without printing the extension (the part after the dot)?

Yishu Fang picture Yishu Fang · Dec 3, 2012 · Viewed 38.5k times · Source

Suppose I have a directory with some files:

$ ls
a.c  b.c  e.c  k.cpp  s.java

How can I display the result without the file extension(the part following the dot, including that dot)? Like this:

$ <some command>
a
b
e
k
s

Answer

Dyno Fu picture Dyno Fu · Dec 3, 2012

using sed?

ls -1 | sed -e 's/\..*$//'