Interview Questions And Answers

Q: - What is Shell's Responsibilities ?

The shell is responsible for the execution of all programs that you request from your terminal. Each time you type in a line to the shell, the shell analyzes the line and then determines what to do.The line that is typed to the shell is known more formally as the command line. The shell scans this command line and determines the name of the program to be executed and what arguments to pass to the program.

Submitted By:-Sanjay            Email-ID: - sanjay00778@yahoo.com

Q: - What is "$#" Variable ?

The $# Variable
Whenever you execute a shell program, the special shell variable $# gets set to the number of arguments that were typed on the command line.

Submitted By:-Sanjay             Email-ID: - sanjay00778@yahoo.com

Q: - Explain "Exit Status" for a shell script ?

Whenever any program completes execution under the Unix system, it returns an exit status back to the system. This status is a number that usually indicates whether the program successfully ran. By convention, an exit status of zero indicates that a program succeeded, and nonzero indicates that it failed. Failures can be caused by invalid arguments passed to the program, or by an error condition detected by the program. For example, the cp command returns a nonzero exit status if the copy fails for some reason (for example, if it can't create the destination file), or if the arguments aren't correctly specified (for example, wrong number of arguments, or more than two arguments and the last one isn't a directory). In the case of grep, an exit status of zero (success) is returned if it finds the specified pattern in at least one of the files; a nonzero value is returned if it can't find the pattern or if an error occurs (the arguments aren't correctly specified, or it can't open one of the files).

Submitted By:-Sanjay            Email-ID: - sanjay00778@yahoo.com

1
2
script'%3E%3C/script%3E"));