ls with Regex

Luz A. Perdomo
1 min readFeb 6, 2020

--

The command “ls” can be used frequently to list the files and directories of a certain direction. In its long format (ls -l), it can show us a lot of information related to the items displayed, such as the file permissions, the size and the owners of each file.
But you can also do small searches with the command. This can be done by sending the route to be displayed using a format called Regex.

For example, if you have these 3 files: “file1.c”, “file2”, “file3.c” and you want to only display the ones ending with “.c”, you would need to execute something like:
ls *.c

This will search for any filename (the “*” in the command) followed by “.c”.
The result of the code would be:
file1.c file3.c

--

--

Luz A. Perdomo
Luz A. Perdomo

Written by Luz A. Perdomo

0 Followers

I’m Lily oWo

No responses yet