What really happens when you type `ls -l *.c` in the shell?

Published on August 25, 2021

By: Selam Ayehubirhan

SHELL


No alt text provided for this image

Shell is an environment in which we can run our commands, programs, and shell scripts.

?It gathers input from you and executes programs based on that input. When a program finish executing, it displays that program's output.

It is a program that takes commands from the keyboard and gives them to the operating system to perform. It is a command interpreter between the user and the computer. It presents a command line interface which allows you to control your computer using commands entered with the keyboard.

The `ls’?command

No alt text provided for this image

?The?ls?command is used to list the contents of a directory.

No alt text provided for this image

?The?ls?command can be used in a number of ways, one of which is by using the option?-l.

If we use the?-l?option with?ls, we would be listing the contents of a directory in a long format.

The long format shows;

·????????The name of the files and subdirectories in the working directory.

·????????The last time the file was modified.

·????????The size of the file in bytes.

·????????The name of the group that has file permissions.

·????????The name of the user who owns the file.

·????????A representation of the file’s access permissions.

No alt text provided for this image

?Wildcards

The shell uses special characters that makes them powerful, these special characters are known as wildcards. Wildcards allow you to select file names based on patterns of characters, one of these wildcards is the asterisks (*).

*” can be used as an argument to match any character. Using wildcards, we can construct selection criteria for filenames.

*?matches all filenames

*.c?matches all filenames that end with the characters?.c

What then happens when we type?ls -l *.c?and hit Enter in a shell?

No alt text provided for this image

?The command?ls -l *.c?from all what we have learnt and as seen above, lists all files ending with?.c?in the current working directory in a long format.

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

社区洞察

其他会员也浏览了