In: Computer Science
use unix
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.