Question

For this Linux script, answer the questions following it: # Sort lines 7 - 26 of...

For this Linux script, answer the questions following it:

# Sort lines 7 - 26 of the file

BEGIN {
idx = 1;
while (getline line<"makefile" ) {
data[idx] = line;
idx++;
}
for (idx2 = 7; idx2 <= 26; idx2++) {
data2[idx2 - 6] = data[idx2];
}
count = asort(data2);
for (idx3 = 1; idx3 < 7; idx3++) {
print data[idx3];
}
for (idx3 = 1; idx3 <= 20; idx3++) {
print data2[idx3];
}
for (idx3 = 27; idx3 < idx; idx3++) {
print data[idx3];
}

}

1) What variables are used by the script? If no variables are used then write "none"

2) How many pattern blocks, including the BEGIN and END blocks, are included in the script? If no blocks are used then write "none".

3) List the awk functions used in the script, and describe the purpose of each function. If no functions are used then write "none".

4) Are there any errors in the script? Does the script accomplish the task that was intended?

5) Are there any improvements that should be made to the script? What are they?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) What variables are used by the script? If no variables are used then write "none"
idx,count

2) How many pattern blocks, including the BEGIN and END blocks, are included in the script? If no blocks are used then write "none".
begin block is there no end , none

3) List the awk functions used in the script, and describe the purpose of each function. If no functions are used then write "none".
none

4) Are there any errors in the script? Does the script accomplish the task that was intended?
yes see attachment , to perform this script successfully it need full script as this has only 7-26 lines

ubuntu17 (fresh) [Running) - OrleVM VirtualBox File Machine View Input Devices Help Activities Terminal Thu 11:22 madhav@madhav-VirtualBox:-/Desktop File Edit View Search Terminal Help madhav@madhav-VirtualBox:- cd Desktop/ madhav@madhav-VirtualBox:~/DesktopS gedit test.sh madhav@nadhav-VirtualBox:-/Desktops bash test.sh test.sh: line 3: BEGIN: command not found test.sh: line 4: idx: command not found test.sh: line 5: syntax error near unexpected token test.sh: line 5: while (getline line< makefile) madhav@nadhav-VirtualBox:-/Desktops 11:22 AM ENG 1511/2018

5) Are there any improvements that should be made to the script? What are they?
seems sorting the data to an array , from seeing this lines logic seems ok

if you have any doubt then please ask me without any hesitation in the comment section below , if you like my answer then please thumbs up for the answer , thanks :)

Add a comment
Know the answer?
Add Answer to:
For this Linux script, answer the questions following it: # Sort lines 7 - 26 of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Answer the following questions using linux 1) Write a Python script so that a file whoComesForDinner.txt...

    Answer the following questions using linux 1) Write a Python script so that a file whoComesForDinner.txt formatted like this:      Tuesday we have Joe McHungry and Paul McHungry Wednesday we have Cindy Johnston and Paul Paulsen Thursday we have Amin Mirzaei and Atefeh Mirzaei gets turned into that: The McHungry on Tuesday Cindy and Paul on Wednesday The Mirzaei on Thursday 2)Write a script that takes as argument a port number. It returns the next port that is not assigned to...

  • Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a...

    Hi, I need help for solving Linux question. . 1.Using the proper text editor, create a shell file called by (your name), your enrollment number, your program and the courses you study. Use the appropriate variables and display the above to the standard output (screen). . 2. Write A Shell Script to perform the following: Display the files and directories Print the date in 24 hour format Display the System id Display the current working directory Print the status of...

  • USING Unix/Linux shell !!!: 1) Write a script (project2.sh) that will take information from a file,...

    USING Unix/Linux shell !!!: 1) Write a script (project2.sh) that will take information from a file, and print (user’s choice of printers) identical form letters to each recipient. Either E197, E-199, E-194 printers or to project2.output. Prompt the user for their choice. 2) The script and output file are due: per Moodle timeline. Please upload your fully functioning script (project2.sh) your data file (project2.input) and your output file (project2.output) into Moodle. 3) Requirements of the script. a. You can use...

  • Please write a BASH Script in LINUX that... 1. is actually executable 2. has a comment...

    Please write a BASH Script in LINUX that... 1. is actually executable 2. has a comment to tell us what you did, why and how. 3. allows a user to enter their name and a number between 1 than 100 (this must be prompted so the user knows what to do) 4. creates a random number between 1 and 100 for you to guess. The command to create a random number is shown below. (if you find a better one...use...

  • The current and voltage data are recorded below every 5 seconds for 1 minute (called a...

    The current and voltage data are recorded below every 5 seconds for 1 minute (called a minute test): time = 5:5:60; current = (16 25 32 40 45 47 44 40 33 26 20 11]; voltage = [2 5 4.5 4.7 5.5 5.4 4.2 3.9 3.3 3 2.8 2.1); a) Write a script that uses cubic equation to model both the current and voltage data as a function of time. The script will plot both sets of data points and...

  • Answer the questions based on following information. 7.     Describe the data collection method(s)'...

    Answer the questions based on following information. 7.     Describe the data collection method(s)' a.     Who collected the data? b.     What tools were used? c.     What were the ethical considerations addressed and discuss gaps you identified. d.     You will need to summarize and analyze the information from the article in your own words Method a quantitative, cross-sectional, descriptive design was chosen for this study. The instrument that was used to collect the data was a self-report questionnaire. a questionnaire previously used...

  • In Unix/Linux, input and output are treated as files and referenced by the operating system using file descriptors. When you open a shell session, for example, three file descriptors are in use: 0 st...

    In Unix/Linux, input and output are treated as files and referenced by the operating system using file descriptors. When you open a shell session, for example, three file descriptors are in use: 0 standard input (stdin) 1 standard output (stdout) 2 standard error (stderr) By default, the command interpreter (shell) reads keyboard input from file descriptor 0 (stdin) and writes output to file descriptor 1 (stdout), which appears on the screen. As you explored in Lab 2, input/output can be...

  • Lesson Assignment There are 13 questions regarding slicing. The first 10 are required to pass. The...

    Lesson Assignment There are 13 questions regarding slicing. The first 10 are required to pass. The last 3 are extra credit. You will place all your answers in the lesson.py tab. Select that tab and take a look at how it's done. For your answers, each function (already defined) returns a tuple: the first item is the answer using index notation (e.g. text[16:20]) the second item is the answer using slice notation (e.g. slice(16,20,None)) the numbers you use for the...

  • LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to...

    LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to a function and returning values. Everything is stored on the runtime stack so that space is used only when the function is executing. As a result the actual address of arguments and locals may change from call to call. However, the layout of the stack frame (activation record) is constant. Thus, the offests from the frame pointer (FP) to the parameters/locals are constant. All...

  • You will write a C program, q1 sequence.c, that computes the value of the nth term...

    You will write a C program, q1 sequence.c, that computes the value of the nth term in any recursive sequence with the following structure: an = c1 · an−1 + c2 · an−2 a0 > 0 a1 > 0 c1 6= 0 c2 6= 0 Your C program will take 5 integer arguments on the command line: n, a0, a1, c1 and c2. n must be an integer greater than or equal to 0. If more or fewer arguments are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT