In my class we had to write a C program and now we have to write a shell
script to do the exact same thing. I am not sure where to get started using
tr and sed to accomplish this assignment. Here is the assignmnet...
--------------------------------------------------------------
(1) remove all non-printing characters (character codes 1 through 31,
and 127) and replace them with the same sort of codes the vi
editor uses. For example, the bell character (character code 7)
is replaced by the two printable characters "^" and "G" (G is the seventh
letter of the alphabet). Appendix I of Foster lists the ASCII character
set, and it shows all the proper two-character sequences that should
be used for the non-printing characters. There are two special cases:
Replace the delete character by "^?". Newlines should be replaced by a
dollar sign ("$") and then an actual newline.
**you may ignore NUL (character code 0)**
(2) delete all non-ASCII characters (those with character codes 128 through
255).
(3) truncate all output lines that would otherwise extend past column 72.
Begin
reading the data on the next line after ignoring the rest of the
character past column 72.
Make sure it reads from stdin and prints to stdout. It should be comprised
of standard UNIX utilities (that is, it should not invoke any specialized C
programs
that you may consider writing). You MUST make use of pipes rather than using
files to store intermediate results. Don't make this assignment
unnecessarily hard: the whole program can be done in ONE line (not counting
all the documentation lines).
--------------------------------------------------------------
I was thinking that (1) could be accomplished by using a tr line like ( tr
'\001-\011' '\136') but that replaces some of the non printing with the ^,
how would i get the letter in there and would I have to have a bunch of
those tr commands piped together just to accomplish (1)?
Some help on this would really really be appreciated as its due on Monday
and I've hit a brick wall on this one.
-mogrefy