This is OK. We want to help people help themselves. This is why we ask for what they have done - even if didn't work - to show them where they have gone wrong.
Further, we have a special forum for "Homework and Coursework" because we do help students alike. The difference is that special rules apply there and we (try to) help in a different way so that the stdent takes the most education out of our help. This was the background of Don Craguns and my questions.
Notice that you do not need "cat" to generate a stream usually. If you look at the man page of "rev" you will notice (this is taken from an AIX man page, yours might look slightly different):
rev Command
Purpose
Reverses characters in each line of a file.
Syntax
rev [ File ... ]
This means the following two lines do the same, but the second one uses one command ("cat") less, which is why it is preferable:
cat /path/to/file | rev
rev /path/to/file
When you look up "useless use of cat" on the internet you will find many more examples for the same error, because it is a very common one, which made it part of the "UNIX culture".
As a matter of fact there are: you might want to learn a bit of sed
(see "man sed" for help) and look around here in the forum. Here a link to some introductory article:
Regular expression introduction
sed
("stream editor") is a non-interactive text editor or, looking at it differently, a programmable text manipulation program. The most basic procedure for this is to look out for some pattern in a text and then manipulate it (delete or add parts, etc.).
Here is a simple sed program:
sed 's/abc/def/' /path/to/input > /path/to/output
It takes a file "/path/to/input", executes the program "s/abc/def/" on it and writes the result to file "/path/to/output". The program itself does a "substitution" ("s") of a fixed string "abc" by a fixed string "def". This replacement is done in every line once - for the first occurrence of "abc". It is possible to replace every occurrence instead by adding a "g" (global) to the end of the command:
sed 's/abc/def/g' /path/to/input > /path/to/output
It should be easy to see how you could do the text manipulation you have in mind with such a substitution, given that you craft the search- and substitution patterns correctly. Since your intention is to learn UNIX i won't tell you outright what the solution is. You might want to try yourself. If you have further questions feel free to ask.
I hope this helps.
bakunin