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

  Writing a c program

Create a C program that has a declaration in main() to store the following numbers into an array named channels: 2, 4, 5, 7, 9, 11, 13. There should be a function call to display().

  Question about damaged database

Suppose if you were one of the users of a damaged database, discuss how would you be affected by such a failure and what measures could you take to prevent it?

  Create binary tree based on names

The Binary Tree is one of best ways to organize information when you require fast access. For this project, we will organize a list of names and perform many operations on those names.

  Explain how to modify knuth-morris-pratt algorithm

Explain how to modify Knuth-Morris-Pratt algorithm to support patterns with these wild cards, and analyze modified algorithm. Your algorithm must find first substring in text which matches the pattern.

  Creating sql statements

Create three SQL statements: the 1st statement should add pending amounts to appropriate accounts, the second statement should subtract the pending amounts from appropriate accounts,

  Computing hash value for message

For a message, he computes the hash value H = (VChar 1 x VChar 2 x VChar 3 ...x VChar N) mod(26).

  Describe algorithm that finds maximum feasible flow in graph

Describe an algorithm that finds a maximum feasible flow in G. Denote by MF(|V|, |E|) the worst-case running time of an ordinary maximum flow algorithm.

  Creating java program using two arrays

Create a program in Java which defines 2-unconstrained arrays of user defined length n, that contain n Random numbers each and which outputs addition of pairs of elements.

  Write algorithm to identify substrings which form numbers

Write the algorithm, by using pseudo code, to do the following task. Given string of numbers, identify all the substrings which form numbers that are divisible by 3.

  What is minimum number of nodes expanded for bfs and dfs

Consider the following graph representing the state space and operators of a navigation problem: What is the minimum number of nodes expanded and the storage needed for BFS and DFS?

  Find shortest path tree by bellman-ford-dijkstra algorithm

Find the shortest path tree from every node to node 1for the graph of following figure using Bellman-Ford and Dijkstra algorithm.

  Using command line options in bash shell script

Design a script that will permit the user to enter one of several choices from the command line. The specific requirements are as follows:

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