using ls command

how do I use ls to list ONLY .txt files?

thanks

# list text files
ls *.txt

# list text files that begin with a number
ls [0-9]*.txt

Etcetera, etcetera.

Hi,

EDIT: i stand corrected :wink:

I don'r think there is an options to do that with ls...best i can think of is ls -F, which flags up all the filenames.....perhaps it would be better to do a GREP on the directory for all the .txt files?

If you do a grep on the directory, it will look inside the files.

ls -alt *.txt | more 

is the way to go.

This will output all the files that are type text, not using ls, but it gets the results you want I think.

file * | grep text | awk '{print $1 }' | cut -d':' -f1

Output is files that are some type of text. For some reason it thinks my sqlscripts are assembler text or English text, sometimes ascii text, but oh well.

i figured it out...it was /home/krad/Unix/fileAsst/*.txt