list files but not directory

Phil Meyer pmeyer at themeyerfarm.com
Sat Aug 22 18:03:20 UTC 2009


ann kok wrote:
> Hi 
>
> any way to list files but not directory
>   

Some time ago, there were at least 116 useful combinations of arguments 
to ls.

UNIX is 40 years old, and ls was there ...

Whenever this question pops up, and it does quite often, I respond with 
a question.

"Why do you want to see just files?"
and
"What file types are you interested in?"

Which usually gets a response like:  "How many different file types are 
there?"  for which the answer is: "At least `egrep -v "^#" 
/usr/share/file/magic | wc -l`" (10179)

There are also some blank lines in the file, but you get the idea.

So now the question is:  "What files types do you want ls to list?"
and
"Did you try the 'F' argument?"

The 'F' argument to ls will attach a single character to the file name 
in order to identify what file types they are.  Of course, only the 
common file types can be identified this way -- there are only some 96 
displayable characters.

So we are back to the original question:

"What is it you are trying to do?"

The answer to that is very likely different from what you expected.

Good luck!




More information about the users mailing list