Purchase Solution

Bash shell scripting questions

Not what you're looking for?

Ask Custom Question

1) Describe the result of executing each of the following grep commands.

a. grep -c ill memo
b. grep -n ill memo

2) Rewrite the following sequence of commands using sort as a filter. The end result should be a single command line when you are done.

sort roster > temp
lp temp
rm temp

3) Write a command to list all files in current directory, that:

a. Start with the letters b or f.
b. Start with the letters a through k.
c. Have a capital letter anywhere in their name.

4) What is the difference between the following commands?

cat xyz[12]
cat xyz[1-2]

5) Listing for which files will be given by the following command?

ls -l file[1-20]

6) Write a Bash script that will prompt for the user's first and last names and store the responses in two variables. Then it will display the stored information in the format "You entered lastname, firstname." and ask the user for confirmation. If the answer is "y" or "yes", then say "Thank you!", and if the answer is "n" or "no" then start again with the prompts.

Purchase this Solution

Solution Summary

Solution also explains the outcome of commands in many cases, giving examples in certain cases. Script implementation makes use of while loop to achieve the goal.

Solution Preview

1)
a. "grep -c ill memo" gives the count of number of lines in the file "memo" that have string "ill" occuring anywhere in them.
b. "grep -n ill memo" prints all the lines in the file "memo" that have string "ill" occuring anywhere in them. Lines are prepended with the corresponding line number separated by a colon.

For example, consider the file "memo" with the following ...

Purchase this Solution


Free BrainMass Quizzes
Excel Introductory Quiz

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

C++ Operators

This quiz tests a student's knowledge about C++ operators.

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.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C# variables and classes

This quiz contains questions about C# classes and variables.