Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use the script file sub discussed on page 678 of your Linux book as a template to complete the following tasks: a) Make two

image text in transcribed
image text in transcribed
Please use the script file "sub" discussed on page 678 of your Linux book as a template to complete the following tasks: a) Make two more copies of file "mysedfile,"created in Lab 6, as "mysedfile2" and "mysedfile3"; b) Create a script file, mysedscript, that will read the files, mysedfile, mysedfile2, and mysedfile3, as its inputs using a for-loop; c) For each file mysedscript reads, please use the sed commands to 1) remove the blank line(s), 2) insert the following record after Nancy's record, and 3) update the files accordingly: Paul 86 94 90 After the execution (remember to chmod x ) of mysedscript, please check whether mysedfile, mysedfile2, and mysedfile3 are updated accordingly. Cut/paste your script file, mysedscript, to a local text document, save it in a text (or pdf format, and then upload it, along with a screenshot of the execution of your mysedscript, to D2L by the deadline . The following bash script changes all occurrences of REPORT TO report, and PROCESS to process in a group of files. Because it is a shell script program file, you must have read and execute permission to the subflus it as a command (page 295). The for structure (page 445) loops throw before processing the file with sed. This program uses embedded sed comma files on the command line. As it processes each file, the script displaystad span multiple lines. Because the NEWLINE between the commands are qui appear between single quotation marks), sed accepts multiple command gle, extended command line within the shell script). Each Substitute includes a global) flag to take care of the case where a string och The program write_demo3 is similar to write_demo2 but precedes the Write tion with the NOT operator (!), causing sed to write to the file those lines motsess 678 CHAPTER 15 THE sed EDITOR 5 cat temp The second sentence. This is sentence four. This is sentence seven. once on a line. $ cat sub for file do echo sfile mv Sfile SS. subhld sed 's/REPORT/report/9 S/FILE/file/g S/PROCESS/process/g' $5.subhld > Sfile done m 55.subhld S sub filel file file filei filez file In the next example, a Write instruction copies part of a file to another file (temp] The line numbers 2 and 4, separated by a comma, select the range of lines sedia copy. This program does not alter the lines. $ cat write_demo2 2.4 w temp2 Ssed -n -f write_demo2 lines $ cat temp2 The second line. The third. This is line four. by the address

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

Students also viewed these Databases questions

Question

=+ 4. How can policymakers infl uence a nations saving rate?

Answered: 1 week ago