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

What happens when you type "ls -l *.c" in the shell

First of all, what is the shell. The shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system to control the execution of the system using shell scripts

The Ls command is the Most used bash command
        

ls?is short for "list" in Linux. It is a?Linux terminal navigation command. So, the command basically lists all the files and directories present in your present working directory. You can provide additional flags and options to the?ls?command to list the contents of some other directory in the same machine.

Using this command without any option will simply list all files and directories without any special pattern representation. It looks like this:

To get more details about the files and directories, we add -l (?long listing format) option to the ls commmand
        
No alt text provided for this image

In this example, the total size of the contents is 105KB.

Then there is an entry for each file/directory in alphabetical order with upper case before lower case.

The first character is the type (e.g. d - directory, l - link).

The next 9 characters show the permissions for the user, group and other.

This is followed by the number of hard links, then the owner's name and group.

The next field is the size in bytes. This can be displayed in a human friendly form by adding the?-h?option e.g. 4088 is displayed as 4.0K

Then followed by a timestamp (usually the modification time).

The final field is the name..

What will happen when adding *.c to the Ls -l command
        
No alt text provided for this image

In the example only .c files are shown.

when *.c added to the ls -l command as shown in the above example only the files ending in ".c" will be listed and all the other files are discarded. Since asterisk or star wildcard tells the program to look for and display files matching the characters after the asterisk. In our case, files ending with ".c" extension will be listed.


By: Abinet Tesfu and Melat Samuel

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

社区洞察

其他会员也浏览了