diez
diez

Reputation: 125

how to view a list of txt file in a folder?

I would like to have only txt file in a folder. i tried cd folder then ls *.txt. I have the good result. but now i would like to have the result using only one linux command. I tried ls *.txt folder and cd folder| ls *.txt.
how to do?

Upvotes: 0

Views: 205

Answers (5)

Vincent
Vincent

Reputation: 666

You can use grep too :

 ls -l folder/ | grep '\.txt'$

Upvotes: 1

TyrantWave
TyrantWave

Reputation: 4673

ls folder/*.txt should do the trick.

Upvotes: 1

fedorqui
fedorqui

Reputation: 290045

You can do the following:

ls folder/*.txt

Upvotes: 2

loentar
loentar

Reputation: 5249

ls folder/*.txt

or

cd folder; ls *.txt

Upvotes: 3

Kasnady
Kasnady

Reputation: 2279

You must cd to the folder first, then just ls *.txt

Upvotes: 0

Related Questions