How to list files having a bunch of them , without die trying.

Jiseth Peña
3 min readJun 8, 2020

On my first work , one of my first tasks was order, adjust and edit thousands and thousands of files in a computer that have a Linux distribution system, that files have to fullfill an amount of characteristics, some of them were: name of files that starts with an specific letter/number etc… , Identify them manually was a really hard task, because i didn't know about the existence of the Terminal application.

The Terminal application allows the users to interact with the Linux system , but this kind of applications not only exist on Linux systems, you can find that on OsX and Windows (as CMD), in this applications you can use commands that help you to do a bunch of things related with the files on the system.

Going back to my story, in that moment i didn't know about the existence of Terminal , but know i know what kind of things you can do with that powerful tool.

Let me show an example of how you can find files with something like an extension.

Imagine that you have a folder like this one:

But you need to filter only the files that finish with the ext .c, so the first thing that you can do is use this powerful Terminal app to list all the files that fullfil that condition.

The command that you are looking for is:

ls

If you give a try to this command on the “ExampleFolder” the result can be something like this:

As you can see the function of ls command is list , and that make sense if you look at the name of the command ls(list). This command have a bunch of options that you can use, but this time remember we need all the files that finish with .c, so lets go for that files…

Now , you can see the magic option that gave us the expected result:

ls *.c

As you can see, on the first time that we use the ls command, Terminal show us on the next 2 lines all the files that are on the current folder (ExampleFolder), but now using the ls *.c you “magically” see the result that only contains the files with the .c ext.

The *.c next to the ls command , gives a pattern to the command that its needed to list files, so the * means that everything and the .c means that everything that finish with .c

In that way you can list files with and specific ext, so from now you can search any kind of file by specifying its extension (.txt .jpg .js .html).

--

--

Jiseth Peña
Jiseth Peña

No responses yet