ls | grep (i dont know what to put here)

Dear users,

I googled for a while, but i have got a lot of different answers regarding a simple unix command.

lets say there are a lot of files in a directory.

How can i list the files in a directory whose file types is "text"?

Thank you in advance

You mean the filenames all end in .text?

ls *.text

actual text files can be any name in UNIX. the file type in the file name is not important like it is in windows.

ls | xargs file | grep 'text'

This finds files that are actually text of some sort.

Or just use

file * | grep 'text'

Code:
ls | xargs file | grep 'text'
This finds files that are actually text of some sort.

This one is great..
Thanks a lot man. Really Thanks a lot.

In solaris, there is a command file which can be used to identify if the file is text or binary file.

bash-3.00$ file 1
1:              commands text

bash-3.00$ file ftpmsg.log
ftpmsg.log:     commands text

bash-3.00$ file temp
temp:           directory

bash-3.00$ file port.tar
port.tar:  USTAR tar archive

So maybe this code can help you:

find . -type f -exec file {} \; |grep " text$"

Thank you for your reply but I will use this one:

ls | xargs file | grep 'text'

looks like sweet and neat
as I only want to display the file of type text.