Shell scripting based questions

Assignment Help Data Structure & Algorithms
Reference no: EM1380648

Question1. Determine will the following only print the text "I FOUND A MATCH" to standard output when the grep is successful?

if grep "mrichard" /etc/passwd; then echo "I FOUND A MATCH"; fi

Question2. Does the following command send both standard output and standard error to the same file for the command cmd1?

cmd1 2>&1 >outfile

Question3. Does cmd2 receive both the standard error and standard output of cmd1 as standard input?

cmd1 2>&1 | cmd2

Question4. Will the script below always print out the text 'They are the same' assuming the script ran under the Bourne shell?

#!/bin/sh
infile=${0}

if [ ! -s "$infile" ]
then
exit 1
fi

linecnt=`wc -l $infile | while read cnt rest
do
echo $cnt
done`

mycnt=0
while read line
do
mycnt=`expr $mycnt + 1`
done < $infile

if [ $linecnt -eq $mycnt ]
then
echo They are the same
else
echo They are different.
fi

5. Does the standard output of this script get sent to STDOUT?

#!/bin/sh

exec 4>&1
exec 1>&2
exec 2>&4
exec 4>&-
echo Hello
echo More text

6. Is the visible output of this script, the text 'Hello'?

#!/bin/sh

(
exec 4>&2
exec 2>&1
exec 1>&4
exec 4>&-
echo Hello
) 2> /dev/null

 

Reference no: EM1380648

Questions Cloud

How could an apparel company use second life to build : How could an apparel company use Second Life to build a digital dashboard to monitor virtual operations? based on the case Second Life: Succeeding in Virtual Times
Describe any constsaints on the ability of businesses : Describe any constsaints on the ability of businesses to respond to external factors.
Describe the difference between transactional and analytical : Describe the difference between transactional and analytical information, and determine which types Spotlight Analysis used to identify its 10 tribes." based on the case Political Micro-Targeting
Prioritize the various exit strategies and explain the order : Prioritize the various exit strategies and explain the order you established. Then, discuss at what point in the business each strategy should be executed along with your rationale.
Shell scripting based questions : Determine will the following only print the text "I FOUND A MATCH" to standard output when the grep is successful? if grep "mrichard" /etc/passwd; then echo "I FOUND A MATCH"; fi
What factors should jorge-marta and jocelyn consider : Jocelyn has little interest in sales or management but would like to invest a large sum of money that she has inherited from her aunt. What factors should Jorge, Marta, and Jocelyn consider in deciding which form of business organization to adopt.
Are the bankruptcy laws in the united states fair to small : Take a position and explain your reasons to the following statement: Are the bankruptcy laws in the United States fair to small business? If you could change the laws, state and justify the specific changes would you make. If you think the laws ar..
Analyze the different ways to evaluate economic performance : Analyze the different ways to evaluate economic performance and determine which provides the best assessment of the economy. Explain your rationale.
Question related to sequential files : In spite of the fact that sequential files lack direct targeted addressing of each of the records and fields, they are the most widely used.

Reviews

Write a Review

 

Data Structure & Algorithms Questions & Answers

  Algorithm to minimize average difference between height

The problem is to assign each skier a ski to minimize the average difference between height of a skier and his/her ski. Give pseudocode and write its asymptotic running time.

  Creating an effective physical design

Class, do IT database designers necessary to understand data volumes and number of users of database in order to create an effective physical design?

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Algorithm to find maximum sum of contiguous sublist

Using dynamic programming, write an algorithm to find the maximum sum of contiguous sublist of a given list of n real values.

  Sort array of elements using the quick sort algorithm

"sort an array of 10,000 elements using quick sort algorithm as follows: sort the array using pivot as middle element of the array

  Describe sorting algorithms and how they work

Describe sorting algorithms and how they work

  Creating relational database about music performers

Create a relational database having information about music performers, their recordings, and the composers of the music they recorded.

  Calculate the cost of sorting relation in seconds

Assume a flash storage device is used instead of disk, and it has seek time of 1 microsecond and transfer rate of 40 MB per second. Recompute the cost of sorting the relation in seconds.

  Design a linked list structure

Design a linked list structure Music that contains data fields Name, Artist, Number_of_Songs, and a pointer to the list. Design the structure with three members and fill in data for each member.

  Write algorithm using pseudo code consensus algorithm

Write an algorithm, using pseudo code, "Consensus algorithm": A group of ten people need to decide which one flavor of ice cream they will all order, out of three options.

  Design benefits election system-service request from huffman

Individual project for this course is in form of Service Request from Huffman Trucking. It is essential for student to access Service Request: SR-ht-001. Design a Benefits Election System.

  Decrypting the ciphertext to recover the plaintext

If you get ciphertext message YPHDCRPBEQTAA, decrypt to recover plaintext.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd