Breaking News
Home / Sys Admin / Unix / How does shell execute an command?

How does shell execute an command?

how does shell command execution works?Shell is the best interface till date that allows system admins to quickly interact with the operating system in UNIX by allowing them to type command in a terminal. Have you wondered how does it resolve these command line instructions and execute it? Let’s see, after the command line is terminated by the key, the shell goes ahead with processing the command line in one or more passes. The sequence is well defined and assumes the following order.<!>

The shell first breaks up the command line into words, using spaces and the delimiters, unless quoted. All consecutive occurrences of a space or tab are replaced here with a single space.

Variable evaluation:

All words preceded by a $ are evaluated as variables, unless quoted or escaped.

Command substitution:

Any command surrounded by back quotes is executed by the shell which then
replaces the standard output of the command into the command line.

Wild-card interpretation:

The shell finally scans the command line for wild-cards (the characters *, ?, [, ]).
Any word containing a wild-card is replaced by a sorted list of filenames that match the pattern. The list of these filenames then forms the arguments to the command.

PATH evaluation:

It finally looks for the PATH variable to determine the sequence of directories it has to search in order to hunt for the command.


Check Also

How to list disks information in Linux?

In order to check the disk in the system we can use the List Hardware …

Advertisment ad adsense adlogger