UNIX Shell Programming Interview Questions You'll Most Likely Be Asked
UNIX Shell Programming Interview Questions You'll Most Likely Be Asked
Programming
Interview Questions
Review these typical interview questions and think about how you would
answer them. Read the answers listed; you will find best possible answers
along with strategies and suggestions.
This page is intentionally left blank
Chapter 1
C Shell – Beginner
1: What must you do before you are able to run your new script
for the first time by its name or with an alias?
Answer:
You must make it executable, that is to execute the command:
chmod +x scriptname
10: What will be the value of the sixrem variable, after executing
this command?
@ sixrem = $data[2] % 6
Answer:
The expression divides the value of second element of the data
array by 6 and assigns the remainder of the division to the sixrem
variable.
14: In tcsh, how are the remaining choices (if any) listed
whenever the word completion fails?
Answer:
The remaining choices (if any), are listed only if the shell variable
autolist is set.
15: In tcsh, how do you disable filename substitution?
Answer:
noglob shell variable can be set to disable the filename substitution
feature.
18: What is the impact of -f option in the first line of a csh script?
(#!/bin/csh
versus
#!/bin/csh -f)
Answer:
When you add the -f option to csh, the shell will skip loading the
startup files .cshrc and resources. It will also skip the hashing
process. The shell will load quicker because of that.
19: How can you start a job in the background, and then
terminate your login session, without terminating the
background job?
Answer:
We can start a job in the background and then terminate our login
session, without terminating the background job using "no
hangup" command, nohup:
nohup command > output_file &
25: Write a pipeline that reads from the j-th line up to the k-th
line of a text file, without using awk.
Answer:
set total = `cat textfile | wc -l`
set j = 10
set k = 18
@ count = $k - $j
head -$k textfile | tail -$count