Purchase Solution

Shell scripting: Few parameter expansion related questions

Not what you're looking for?

Ask Custom Question

Give brief answers for the following questions.

1. Can an until loop sometimes never execute?

2. Will the following script execute with no errors?

#!/bin/csh
for I
do
echo $I
done

3. Does the following script print to standard output, a list of numbers equal to the number passed on the command line?

#!/bin/sh

count=$1

index=1
while [ "0$index" -le $count ]
do
echo $index
index=`expr "$index" + 1`
done

4. Will the following statement print 'I am glad this class is over' to standard output if the shell variable XYZ is NULL or not set?

: ${XYZ:?"I am glad this class is over"}

5. After the statement

: ${VISUAL:=vi}

will the value of the shell variable VISUAL always be vi?

6. Will the following command execute:

${VISUAL:+vi} ls

the command 'ls' if the shell variable VISUAL is not set or null?

7. Will the following commands send to the line printer all files whose contents contain the text '/bin/sh' if the command to print is lpr ?

MATCH=`grep -l '/bin/sh' *`
lpr ${MATCH?"NO files found"}

Purchase this Solution

Solution Summary

Solution also gives reasons/examples in many cases.

Solution Preview

1. Yes, sometimes an until loop will never execute. Consider the example given below.

#!/bin/bash
myvar=5
until [ $myvar ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic Networking Questions

This quiz consists of some basic networking questions.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.