Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having some trouble in completing an assignment about advanced bash shell, nothing I do seems to work. Below are the instructions for it: -

I'm having some trouble in completing an assignment about advanced bash shell, nothing I do seems to work. Below are the instructions for it:

- Write some code in advscript.sh that will create two empty text files in the current directory, named input.txt and output.txt

- Add some code to advscript.sh that will insert 1000 lines of text into the input.txt file. Each line of text will consist of a three-digit number, and every line will contain a unique number. Start with 000, and count up to 999.

- Add some more code to advscript.sh that will read input.txt line-by-line. Add up the three digits on each line, and determine whether the resulting sum is "odd" or "even". Output each number line-by-line, along with odd or even appended to the end into output.txt

Additional "hints":

- The easiest way to create zero-padded consecutive numbers like these is by using "brace expansion". While you could use nested loops as well, that method will be a lot more cumbersome.

- Use a redirect to echo text into the files. Remember that one type of redirect overwrites the entire contents of the file, while the other redirect simply appends to the file.

- Use the "touch" command (touch filename.txt) or simply the redirect operator by itself (> filename.txt) to create the empty files.

- To determine whether a number is even, use the modulus operator (%) with a divisor of 2. If the result of this operation equals zero, you know that the number is even. If the modulus result doesn't equal zero, then the number is odd.

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

What is operatiing system?

Answered: 1 week ago