How to use the ls *.c command on Linux?

How to use the ls *.c command on Linux?

The ls command is one of the most useful and basic commands in Unix-like operating systems and is used to list the names of the files and directories inside a specific folder. Next is the structure of the ls command.

Command Structure:

ls [option] [file]

This time we are going to be focused in the use of ls command along with a wildcard on the next form: ls *.c

However, before going any further on this topic we should make clear that a wildcard is a character that matches or expand specific types of patterns in order to make efficient searches through the file system. For the command we are applying, we use the character '*' known as the star character that can match any string of any length.

Summing up the last definitions we have that ls *.c will list all the files and folders that end with a .c and to have a better understanding of each one of this parts we are going to make a step-by-step guide as shown below:

  • First, we use ls command alone, and as we saw before the command lists the files and directories in the current working directory.
Use of command ls
  • Then we are going to add the star character '*' after the ls command with the intention to list the files and folders, but also the files inside the subdirectories of the current working directory.
No hay texto alternativo para esta imagen
  • Finally we add the .c along the '*' character in order to match all the files and folders ending with a .c
No hay texto alternativo para esta imagen



要查看或添加评论,请登录

Valentina Jaramillo Ramirez的更多文章

  • Compilation Process

    Compilation Process

    Hello there! Today we are going to review some concepts about compilation, the use of gcc as a compiler, and understand…

  • What you need to know about Hard Links and Symbolic Links.

    What you need to know about Hard Links and Symbolic Links.

    Welcome. Today we are going to learn about Hard links and Symbolics links, the difference between them, and how to…

社区洞察

其他会员也浏览了