Question

In: Computer Science

You are given an array as below: IFS=", " #set IFS to be a comma. MYARRAY=(101,102,103,105)...

You are given an array as below:
IFS=", " #set IFS to be a comma.

MYARRAY=(101,102,103,105)

Which of the following structure can be used to expand an array?

${MYARRAY[]}
${MYARRAY[?]}
${MYARRAY[@]}
${MYARRAY[!]}

Which of the following is a test statement that can be used with while or if or elif statements?

#Initialized variables are as below

i=0 #variable i initialized to be 0

[$i -lt 10]
{$i -lt 10}
($i -lt 10)
[i -lt 10]

Which of the following variable stores the first argument given to a shell program command?
#
2
1
3

You executed a command as below on a terminal

$grep -n "hello" myfile.txt

What is the value of exit status variable "?" if the command returns an empty output?
none
0
1
2

A variable '!' used by a program is used to store the number of argument to a shell command.
T/F

-f is an operator to check if a regular file exist in a directory. It is used as:

if test -f myfile.txt

then

echo "file exists"

else

echo "file does not exist"

fi


True

False

Solutions

Expert Solution

1.Which of the following structure can be used to expand an array?

Ans:

${MYARRAY[@]} //or you can also use ${MYARRAY[*]}

2.

Which of the following is a test statement that can be used with while or if or elif statements?

#Initialized variables are as below

i=0 #variable i initialized to be 0

Ans:

[$i -lt 10]

3.Which of the following variable stores the first argument given to a shell program command?

Ans: 1

#0 is used to store filename, # is used to count the arguments

4.You executed a command as below on a terminal

$grep -n "hello" myfile.txt

What is the value of exit status variable "?" if the command returns an empty output?

Ans: 1 #if pattern found, stus code will be 0

5.A variable '!' used by a program is used to store the number of argument to a shell command.

Ans: False. # to store the number of arguments '#' variable is used.

6.f is an operator to check if a regular file exist in a directory. It is used as:

if test -f myfile.txt

then

echo "file exists"

else

echo "file does not exist"

fi

Ans: True


Related Solutions

In the class MyArray, write a method named indexAndCountOfMax that on an input array of numbers,...
In the class MyArray, write a method named indexAndCountOfMax that on an input array of numbers, finds and returns (1) the smallest index of the largest element of the array and (2) the number of times the largest element occurs in the array. The header of the method should be public static int[ ] indexAndCountOfMax (double[ ] A). The method should return an array of length 2, where the value at index 0 is the smallest index of the largest...
write the code that declares an array of booleans, called myarray, with size of 40 elements
write the code that declares an array of booleans, called myarray, with size of 40 elements
Create a class and name it MyArray. This class must have an internal array of integers...
Create a class and name it MyArray. This class must have an internal array of integers and the consumer should specify the maximum capacity when instantiating. MyArray class must provide following functions: 1- insert: This method receives and integer and inserts into the array. For simplicity you can assume the array is large enough and never overflows. 2- display: This method displays all integers stored in the array in the same order as they are inserted (first in first out)....
Say I have and Array so MyArray starts off as S A Q W A R...
Say I have and Array so MyArray starts off as S A Q W A R .... I want to sort the Array alphabetically using ascii codes to sort. However in Ascii code capital letters come first and then lower case letters are sorted after. My goal is to not only sort the array, but also make lowercase sorted in its proper place. I am using visual basics and I cant use a built in sorter that does it the...
Explain if the set below is a vector space given standard operations. The set of all...
Explain if the set below is a vector space given standard operations. The set of all even functions defined on R with addition and scalar multiplication defined as follows: 1.) (f+g)(x) = f(x) + g(x) (addition) 2.) (cf)(x) = cf(x)
Direction: A small data set is given below. You will run a t-test using Excel. You...
Direction: A small data set is given below. You will run a t-test using Excel. You must provide Excel output to get full credit for this question. A medical researcher wants to determine whether a drug changes the body’s temperature. Seven test subjects are randomly selected, and the body temperature (in degrees Fahrenheit) of each is measured. The subjects are then given the drug and after 20 minutes, the body temperature of each is measured again. The results are listed...
Suppose you are given the following array X = [7, 9, 1, 6] Sort the array...
Suppose you are given the following array X = [7, 9, 1, 6] Sort the array in ascending order using the selction sort algorithm. Write the state of the array after each pass. Pass1: Pass2: Pass3: Suppose you are given the following array X = [7, 9, 1, 6] Sort the array in ascending order using the selction sort algorithm. Write the state of the array after each pass. Pass1: Pass2: Pass3:
You are given an array of n elements, and you notice that some of them are...
You are given an array of n elements, and you notice that some of them are duplicates, that is, they appear more than once in the array. Show how to remove all duplicates from the array in time O( n log2 n ).
Question 1: A small data set is given below. You will run a t-test using Excel....
Question 1: A small data set is given below. You will run a t-test using Excel. In order to receive full credit, you must turn in Excel output and your final answers. Round off final answers to three decimal places, if appropriate. A medical researcher wants to determine whether a drug changes the body’s temperature. Seventest subjects are randomly selected, and the body temperature (in degrees Fahrenheit) of each is measured. The subjects are then given the drug and after...
A data set is given below. ​(a) Draw a scatter diagram. Comment on the type of...
A data set is given below. ​(a) Draw a scatter diagram. Comment on the type of relation that appears to exist between x and y. ​(b) Given that x̅ = 3.8333​, Sx = 2.4014 ​, ȳ equals = 3.7333 3.​, Sy = 1.8381​, and r = -0.9545 ​, determine the​ least-squares regression line. (c) Graph the​ least-squares regression line on the scatter diagram drawn in part x   y 0   5.9 2   5.7 4   4.3 5   2.8 6   1.7 6   2...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT