j1nma
j1nma

Reputation: 467

Linux Terminal: how to view files with extension using ls command?

How can I use the ls command to print all of those files with a .doc extension inside the "tmp" directory? (No find neither grep). Perhaps with -X ? How would it be if we used -X?

Upvotes: 0

Views: 7005

Answers (3)

Jordan Robinson
Jordan Robinson

Reputation: 865

If you're adamant on not using grep or find, as outlined here:

https://stackoverflow.com/a/1447974/1666167

You can do something like this:

ls *.{mp3,exe,mp4}

What this looks like for .doc files in the tmp directory is this:

ls /tmp/*.doc

Upvotes: 3

Andrzej Pałkowski
Andrzej Pałkowski

Reputation: 11

Try this one, should work:

 ls *.doc

Upvotes: 1

Bey0ndZ
Bey0ndZ

Reputation: 114

You could do something like: ls *.doc in the directory.

Upvotes: 1

Related Questions