Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write this in Linux 11. [20pts] Write a shell script that only prints the odd numbered lines of each file in the current directory,

Please write this in Linux

image text in transcribed

image text in transcribed

11. [20pts] Write a shell script that only prints the odd numbered lines of each file in the current directory, except for the script itself. The output should be filename: line for each odd numbered line. You do not need to print line numbers. Bonus [10pts]: write the script in a way that it works no matter the filename given to the script. For example, let's say I write a script in a file called test.sh. I then create 3 files, as shown in the screenshot below: mininetemininet-um="/tests cat file1 line 1 line 2 line 3 line 4 line 5 mininetemininet-um:/tests cat file2 line 1 line 2 line 3 line 4 line 5 mininetemininet-um/tests cat file3 line 1 line 2 line 3 line 4 line 5 My directory now looks like the following: mininetemininet-um:"/tests ls -la total 36 drwxrwxr-x 2 mininet mininet 4096 Jan 12 11:18. drwxr-xr-x 17 mininet mininet 4096 Jan 12 11:18 .. -rw-rw-r-- 1 mininet mininet 35 Jan 11 01:30 file1 -rw-rw-r-- 1 mininet mininet 35 Jan 11 01:30 file2 -rw-rw-r-- 1 mininet mininet 35 Jan 11 01:30 file3 -ruxrwxr-x 1 mininet mininet 203 Jan 11 01:39 test.sh When I run the script, the output should look like the following. mininet@mininet-vm:-/test$ ./test.sh filel: line 1 filel: line 3 filel: line 5 file2: line 1 file2: line 3 file2: line 5 file3: line 1 file3: line 3 file3: line 5

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_2

Step: 3

blur-text-image_3

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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions