Share
Explore BrainMass

Various Shell Scripting Jobs in Knoppix using vi, tail, diff

I am using KNOPPIX 4.0

In your week2 directory create two identical files.
Mollett.ed1
Mollett.vi

The contents of the two files should be:
There once was a man from Nantucket,
Who carried his lunch ina bucket,
Saih he with a sigh,
I am very full As he ate a whole pie,

Using an editor available in your Konsole window that is not the vi editor edit the *.ed1 file:

Add the following line after the last line:

If I just had a donut I'd dunk it.

Remove all text on the fourth line before the word As

Correct misspelled words ina and Saih

Save the file and exit the editor

Using the vi editor on the *.vi file
Add the following line after the last line:

If I just had a donut I'd dunk it.

Remove all text on the fourth line before the word As

Correct misspelled words ina and Saih

Change the limerick so it reflects a woman instead of a man (change all

occurrences of man to woman, his to her, and he to she) using search and replace feature

Save the file and exit vi

Place the word count of the two files in a file called Mollett.out

Change Nantucket to Pawtucket in the *.ed1 file using the sed command
Append the last two lines of each file to the file called Mollett.out without cutting and pasting (Hint: tail command can do this)
Find the differences between the two files and append the result to the file called Mollett.out (Hint: diff command can do this)
Use grep to find files contaning Pawtucket and append the output to the file called Mollett.out
In your week2 directory create the script in Project.3-7 and name it Mollett.3-7

Attach your four files to a message posted in the Assignments NG

Solution Preview

joe Mollett.ed1
type text
close file
cp Mollett.ed1 Mollett.vi
choose joe as the editor since it's nice and intuitive like windows editors
type joe Mollett.ed1
Add the line and then take the cursor on "I" the first word of the 4th line then press CTL+k+b together
now use the right arrow to bring the curson to the space before 'A' of "As" and press CTRL+k+k.
Next press CTRL+k+y and you you will see that the block has disappeared.
move to the third line and change "Saih" to "Said".
move to the third line and change "ina" to "in a".
once you are done press CTRL+k+x to save the file and return to prompt.

now use vi to open the other file
type vi Mollett.vi
using the arrow key bring the cursor to the last ...

Solution Summary

Various Shell Scripting Jobs in Knoppix using vi, tail, diff and working with files.
Explains in detail with example.

$2.19