Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use Linux to write the following question: Write a shell script that only prints the odd numbered lines of each file in the current
Please use Linux to write the following question:
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.
Write the script in a way that it works no matter the filename given to the script.
For example, lets say I write a script in a file called test.sh. I then create 3 files(file1,file2,file3), as shown in the screenshot below:
mininetOmininet-um/testS cat file1 line 1 line 2 line 3 line 4 line 5 mininetCmininet-um:test$ cat file2 line 1 line 2 line 3 line 4 line 5 mininetCmininet-um:/test cat file3 line 1 line Z line 3 line 4 line 5Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started