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

  Write schedule produced by earliest deadline first algorithm

Given below are two sets of real-time, periodic tasks. For (a), will the schedule produced by Earliest Deadline First algorithm meet all the deadlines?

  Java program to assign passengers seats in airplane

Prepare a Java program to assign passengers seats in an airplane. Suppose a small airplane with seats numbered as follows:

  Simplify rsa cryptosystem using prime number

Assume we tried to simplify RSA cryptosystem using just prime p instead of composite modulus N = pq. As in RSA, we would have encryption exponent.

  Advantage of fast running time of insertion sort

Running time of quicksort can be enhanced in practice by taking advantage of fast running time of insertion sort when its input is "nearly" sorted.

  Creating villian

Announce a new Villian called sharpay who has a wit of 24, a stealth of sixteen, and who has currently claimed three victims: Chad, Troy, and Gabriella.

  Creating visual studio asp .net web site

Make a Visual Studio 2008 ASP .NET Web Site with 2-Web Forms. Add a DropDownList server control and a Label server control to 1st Web Form.

  Sort scheduling algorithms according to high throughput

Sort the scheduling algorithms (FCFS, SPF, RR, MLFB) according to each of High throughput (if we take averages of time intervals smaller than the sum of all processes' time)

  Question about key encryption

Assume Alice wishes to send an e-mail to Bob. Bob has a public private key pair, Alice has Bob's certificate. But Alice does not have a public, private key pair.

  Describe properties of bfs and dfs for acyclic tree

Analyze the given properties of BFS and DFS for Acyclic Tree without making any assumptions. Optimality, Completeness.

  Object identifier tree

Assume you worked for a United States based corporation that wanted to develop its own MIB for managing a product line. Where in the object identifier tree would it be registered?

  Java program to make choice for a coffee cup size

Create an application that prompts the user to make a choice for a Coffee cup size, S for Small, T for Tall, G for Grande and V for Venti the rates of cup sizes will be stored in a parallel double array as $2, $2.50, $3.25, and $4.50 respectively.

  Algorithm to read arbitrary number of data records

Write the algorithm to read arbitrary number of data records, each comprising name, age, and code.

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