Question

In: Computer Science

use unix Move lines 3 through 5 after line 8 (so the output lines would be...

use unix

  1. Move lines 3 through 5 after line 8 (so the output lines would be in order 1,2,6,7,8,3,4,5,9,10,....)
  2. Given a line with a UNIX path specified, print the base file name only. So for example, "/home/users/james" would print "james"
  3. Given a line with a UNIX path specified, print the directory part only. So for example, "/home/users/james" would print "home/users"

Solutions

Expert Solution

Move lines 3 through 5 after line 8 (so the output lines would be in order 1,2,6,7,8,3,4,5,9,10,....)

Answer:

I'll be using an awk command in order to execute this.

awk command searches files for text containing a pattern. When a line or text matches, awk performs a specific action on that line/text. The Program statement tells awk what operation to do;

Program statement consists of a series of "rules" where each rule specifies one pattern to search for, and one action to perform when a particular pattern is found.

Code:

awk 'NR==3,NR==5{a[i++]=$0;next} NR==8{print;for(c=0;c<i;c++){print a[c]}next1' file

Awk NR gives you the total number of records being processed or line number

I have a used a for loop in order to acieve the given task done in a single command line argument in Unix

Original Input:

Expected Output:

I could only complete the first part since it had a lot of try and error and I ran out of time. Please Re-Post for receiving answers on the other questions.

If you have any doubts, leave a comment below before rating. I'll be happy to assist you further.

Please UPVOTE as I have put a lot of EFFORT in answering this question. It really helps me.


Related Solutions

An electronic product takes an average of 8 hours to move through an assembly line. If...
An electronic product takes an average of 8 hours to move through an assembly line. If the standard deviation of 0.7 hours, what is the probability that an item will take between 7.3 and 8.3 hours to move through the assembly line? Do not round until you get your your final answer. Answer= (Round your answer to 4 decimal places, and report a probability value between 0 and 1.)
(a) Find parametric equations for the line through (3, 4, 8) that is perpendicular to the...
(a) Find parametric equations for the line through (3, 4, 8) that is perpendicular to the plane x − y + 4z = 5. (Use the parameter t.) (x(t), y(t), z(t)) =    (b) In what points does this line intersect the coordinate planes? xy-plane     (x, y, z) =    yz-plane     (x, y, z) =    xz-plane     (x, y, z) =   
please use linux or unix to complete, and include pictures of the output. Modify the code...
please use linux or unix to complete, and include pictures of the output. Modify the code below to implement the program that will sum up 1000 numbers using 5 threads. 1st thread will sum up numbers from 1-200 2nd thread will sum up numbers from 201 - 400 ... 5th thread will sum up numbers from 801 - 1000 Make main thread wait for other threads to finish execution and sum up all the results. Display the total to the...
The insertion of an "A" immediately after (3' of) the "A" in the codon 5'-CAG-3' would...
The insertion of an "A" immediately after (3' of) the "A" in the codon 5'-CAG-3' would cause what type of mutation? Synonymous, or silent, mutation B. Anti-sense mutation C. Non-sense mutation D. noisy mutation E. Non-synonymous mutation
Using sed unix / linux command how would I execute this: Move the first 2 characters...
Using sed unix / linux command how would I execute this: Move the first 2 characters on each line to the end of the line
Fill in the blanks of the following segment of code, so that the output would be 1 3 4.
Fill in the blanks of the following segment of code, so that the output would be 1 3 4.int count = 0;do{++ count;if (count == 2)Blank;cout << count << " ";} while (count <= Blank);cout << endl;
1. Find the equation of the line with the given description: Horizontal, passes through (0,−8)(0,−8). (Use...
1. Find the equation of the line with the given description: Horizontal, passes through (0,−8)(0,−8). (Use symbolic notation and fractions where needed.) y= 2. Find the equation of the line with the given description: Passes through (−1,6)(−1,6) and (12,10)(12,10). (Use symbolic notation and fractions where needed.) y= 3.Find the equation of the vertical line, passes through (76,89).(76,89). (Use symbolic notation and fractions where needed.) x= 4.Determine whether there exists a constant cc such that the line x+cy=−3x+cy=−3 Has slope −8−8...
Through Decoupling and Line of Visibility how you would use the Theory of Constraints with the...
Through Decoupling and Line of Visibility how you would use the Theory of Constraints with the system/theory below to create an effective process?
Find the equation of the line goes through (1,0,-1) that is perpendicular to the lines x...
Find the equation of the line goes through (1,0,-1) that is perpendicular to the lines x = 3+2t,y = 3t,z = −4t and x = t,y = t,z = −t. Write it in parametric and the vector equation form.
Use the following data Row 1- 1, 3, 3, 3, 5, 5, 6, 6, 7, 8...
Use the following data Row 1- 1, 3, 3, 3, 5, 5, 6, 6, 7, 8 Row 2- 94, 87, 83, 73, 91, 68, 74, 82, 65, 65 A. Find the equation of the regression line for the given data, row 1 represent the x values and row 2 the y values. Sketch a scatter plot of the data and draw the regression line. Input the values of the slope for the regression line when Row 1 represents the x...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT