How to list files in a very efficient way?!

How to list files in a very efficient way?!

What does the ls *.c instruction do at the conceptual level? (regardless of the language used)

Lists the files in the current directory that end in “.c”. You do not understand it?! Take it easy, below I will let you know all the steps you need to know in order to understand it.

Basic concepts

If you have worked in Linux, you may be familiar with the?ls?command. But for everyone else "Ls" is short for “list”. This command lists information about directories and any type of files in the working directory. Let’s start by explaining the syntax of the?ls?command.

No alt text provided for this image

[options]?– This lets you add additional instructions to the?ls?command. Example that we will be provided in the following sections of the article is about listing all articles that have a specific identifier regarding the files we want to list.

Explanation of the command step-by-step

In the command ls -l *.c we are going to separate this command step-by-step in order to understand how all this commands are linked together. "ls -l"?command is used to print out a long listing format of files and directories. The output displays information, such as file or folder name, owner of the file and its permission, size and modified date and time as in the image below:

No alt text provided for this image

The '*' here is a?wildcard, which matches any number of characters. In Linux if you use '*' and adding every argument after and before it, helps you to check all those files that have those arguments before or after that sign. On our case we are looking to list all the files that ends with ''.c" in long format including information file name, owner of the file and its permissions, size and modified time and date.

Now, what does the instruction ‘ls * .c’ do?

It lists (with the command ls) the current directory (which is the default option of the ls command) the files — files and directories — that start with anything but that necessarily end in ‘* .c’. Then, it reprints you the prompt, giving you again the entry to the Shell.

No alt text provided for this image

Stay tuned for more informative blogs! Made by Eno Gupe & Donaldo Kumaraku

Mucaj Elvin

Developer Engineer at Digitalb

2 年

ls -aril *.c | grep '*str*'

回复

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

Eno Gupe的更多文章

  • Mutable, Immutable... everything is object!

    Mutable, Immutable... everything is object!

    Let's suppose that you want to change something on your body. You can change color of your hair, quantity or style of…

  • Class and instance attributes

    Class and instance attributes

    Hello my readers! I would like to thank you upfront for your time while reading this new article. Today I will write…

  • Static library in C

    Static library in C

    A library is a collection of code routines (functions, classes, variables, and so on) that can be called upon when…

社区洞察

其他会员也浏览了