Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Basic bash Goals The purpose of this lab is to help you to get familiar with Unix in the following aspects: - Create a bash

Basic bash

Goals

The purpose of this lab is to help you to get familiar with Unix in the following aspects:

- Create a bash file and run it.

- Learn about positional parameters.

Q1. Create a folder called lab2.

Q2. Create a bash file that is called (bashFile.sh) (20 points)

#! / bin /bash

echo "Hello World!

Run the bash file with the command bash bashFile.sh.

3. Test positional parameters

#! / bin /bash

echo "Positional Parameters"

echo ' $0 = ' $0

echo ' $1 = ' $1

echo ' $2 = ' $2

echo ' $3 = ' $3

positionalParameters.sh

Q4. Self-reproducing Script (20 points)

Write a script that backs itself up, that is, copies itself to a file named backup.sh.

Hint: Use the cat command and the appropriate positional parameter.

Q5. Backwards Listing (20 points)

Write a script that echoes itself to stdout, but backwards.

Q6. Changing the line spacing of a text file (40 points)

Write a script that reads each line of a target file, then writes the line back to stdout, but with an extra blank line following. This has the effect of double-spacing the file.

Include all necessary code to check whether the script gets the necessary command-line argument (a filename), and whether the specified file exists.

When the script runs correctly, modify it to triple-space the target file.

Finally, write a script to remove all blank lines from the target file, single-spacing it.

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

=+j Improve the effectiveness of global and virtual teams.

Answered: 1 week ago