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;
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.
1.) Write a​ slope-intercept equation for a line passing through the point (5,−3) that is parallel...
1.) Write a​ slope-intercept equation for a line passing through the point (5,−3) that is parallel to the line 5x+7y=8. Then write a second equation for a line passing through the point (5,−3) that is perpendicular to the line 5x+7y=8. 2.) Write a​ slope-intercept equation for a line passing through the point (4,−3) that is parallel to the line 4x+5y=7. Then write a second equation for a line passing through the point (4,−3) that is perpendicular to the line 4x+5y=7....
Using Netbeans update the Sales project so the input and the output are done through a...
Using Netbeans update the Sales project so the input and the output are done through a GUI of your choice. The classes design should not be changed, only the code in the test class. public abstract class Account { private int accountId; public Account(int id){ this.accountId=id; } //getters public int getAccountId() { return accountId; } //setters public void setAccountId(int accountId) { } //abstract method to calculate sales public abstract double calculateSales();    //to string method @Override public String toString() {...
Use SPSS to get the appropriate output. Along with providing the SPSS output, use the 5...
Use SPSS to get the appropriate output. Along with providing the SPSS output, use the 5 steps of hypothesis testing to analyze the results by using the p-value approach. 4. Workers went through a training program to help them in the packaging of items needed for the purchaser to assemble a toy. The number of defective packages returned per month is recorded for each employee doing the packaging. Below are the before and after number of defects per month per...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT