• LOGIN
  • No products in the cart.

Unix Shell Scripting Interview Questions

What is a UNIX shell?
The UNIX shell is a program that serves as the interface between the user and the UNIX operating system. It is not part of the kernel, but communicates directly with the kernel. The shell translates the commands you type in to a format which the computer can understand. It is essentially a command line interpreter.

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.

What is $*?
It’s mainly used for showing up all params. This show all parameter values passed in shell script

What does $# stand for?
# will return the number of parameters that are passed as the command-line arguments.

What does $? Return?
$? will return exit status of command .0 if command gets successfully executed, non-zero if command failed.

What are Different types of shells?
sh: the oldest shell
csh: C shell
ksh: Korn Shell
bash: bourne again shell

What are the different kinds of loops available in shell script?
for, if, while, case

What is “Command Substitution”?
Command substitution is the process by which the shell runs a command and replaces the command substitution with the output of the executed command. That sounds like a mouthful, but it’s pretty straightforward in practice.

What is “eval” command?
The eval command exists to supersede the normal command-line substitution and evaluation order, making it possible for a shell script to build up commands dynamically. This is a powerful facility, but it must be used carefully. Because the shell does so many different kinds of substitutions, it pays to understand the order in which the shell evaluates input lines.

Unix Admin Training

What is awk?
An awk invocation can define variables, supply the program, and name the input files.

What is “grep” program?
The grep program is the primary tool for extracting interesting lines of text from input data files. POSIX mandates a single version with different options to provide the behavior traditionally obtained from the three grep variants: grep, egrep, and fgrep.

What is Interactive mode?
Interactive mode means that the shell expects to read input from you and execute the commands that you specify. This mode is called interactive because the shell is interacting with a user. This is usually the mode of the shell that most users are familiar with: you log in, execute some commands, and log out. When you log out using the exit command, the shell exits.

What is noninteractive mode?
In this mode, the shell does not interact with you; instead it reads commands stored in a file and executes them. When it reaches the end of the file, the shell exits.

what is local variable?
A local variable is a variable that is present within the current instance of the shell. It is not available to programs that are started by the shell. The variables that you looked at previously have all been local variables.

What is shell variable?
A shell variable is a special variable that is set by the shell and is required by the shell in order to function correctly. Some of these variables are environment variables whereas others are local variables.

What is GUI Scripting?
Graphical user interface provided the much needed thrust for controlling a computer and its
applications. This form of language simplified repetitive actions. Support for different applications mostly depends upon the operating system. These interact with menus, buttons, etc.

What is this line in the shell script do? #!/bin/ksh?
To invoke the shell indirectly this line is added as the first line in the file. This particular line invokes korn shell.

Explain “Escape Sequence”?
An escape sequence is special sequence of characters that represents another
character.

Explain “Output Redirection” in shell scripting?
In UNIX or Linux, the process of capturing the output of a command and storing it in a file is called output redirection because it redirects the output of a command into a file instead of the screen.

Explain “Input Redirection” in shell scripting?
In UNIX or Linux the process of sending input to a command from a file is called input redirection.

Unix Training

What is “Field separator”?
The field separator controls the manner in which an input line is broken into fields. In the shell, the field separator is stored in the variable IFS. In awk, the field separator is stored in the awk variable FS.

What is “Library”?
A file that contains only functions is called a library. Usually libraries contain no main code

November 22, 2019
GoLogica Technologies Private Limited  © 2019. All rights reserved.