# using ls command

**URL:** <https://community.unix.com/t/using-ls-command/185449>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [February 13, 2008, 6:05pm UTC](https://community.unix.com/t/using-ls-command/185449 "2008-02-13T18:05:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kylethesir](https://community.unix.com/letter_avatar/kylethesir/32/6_449c533f586939b6e5f246632a46421f.png) [@kylethesir](https://community.unix.com/u/kylethesir)\
**Post date:** [February 13, 2008, 6:05pm UTC](https://community.unix.com/t/using-ls-command/185449/1 "2008-02-13T18:05:43Z")

</div>

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

thanks

---

<div class="post-metadata">

**Author:** ![gus2000](https://community.unix.com/letter_avatar/gus2000/32/6_449c533f586939b6e5f246632a46421f.png) [@gus2000](https://community.unix.com/u/gus2000)\
**Post date:** [February 13, 2008, 6:41pm UTC](https://community.unix.com/t/using-ls-command/185449/2 "2008-02-13T18:41:55Z")

</div>

```nohighlight
# list text files
ls *.txt

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

```

Etcetera, etcetera.

---

<div class="post-metadata">

**Author:** ![elduderino](https://community.unix.com/letter_avatar/elduderino/32/6_449c533f586939b6e5f246632a46421f.png) [@elduderino](https://community.unix.com/u/elduderino)\
**Post date:** [February 13, 2008, 6:49pm UTC](https://community.unix.com/t/using-ls-command/185449/3 "2008-02-13T18:49:02Z")

</div>

Hi,

EDIT: i stand corrected 😉

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?

---

<div class="post-metadata">

**Author:** ![matt.d](https://community.unix.com/user_avatar/community.unix.com/matt.d/32/831_2.png) [@matt.d](https://community.unix.com/u/matt.d)\
**Post date:** [February 21, 2008, 9:27pm UTC](https://community.unix.com/t/using-ls-command/185449/4 "2008-02-21T21:27:01Z")

</div>

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

```nohighlight
ls -alt *.txt | more 

```

is the way to go.

---

<div class="post-metadata">

**Author:** ![olenkline](https://community.unix.com/letter_avatar/olenkline/32/6_449c533f586939b6e5f246632a46421f.png) [@olenkline](https://community.unix.com/u/olenkline)\
**Post date:** [February 26, 2008, 2:18pm UTC](https://community.unix.com/t/using-ls-command/185449/5 "2008-02-26T14:18:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kylethesir](https://community.unix.com/letter_avatar/kylethesir/32/6_449c533f586939b6e5f246632a46421f.png) [@kylethesir](https://community.unix.com/u/kylethesir)\
**Post date:** [May 27, 2008, 8:13pm UTC](https://community.unix.com/t/using-ls-command/185449/6 "2008-05-27T20:13:25Z")

</div>

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