| View Blog
|
|
|
|
| The Joys of Sex |
Oops that should have read 'The Joys of Text' , slight slip of the typing fingers. Still now that you are here I wanted to share my experiences of the last year switching from bloat ware such as MS Office and moving to plain ASCII text files.
I think I can hear the gears churning , Why? Why switch to plain ASCII text files when you can do so many fancy things with MS Word or Open Office Writer. There's lot's of great software that do great things too, such as out-liners, mind mappers and so on... why on earth limit yourself to plain old ASCII text files?
This is a very good question and one I shall try to answer and demonstrate with simple examples taken from my own PC. As a Unix systems administrator and Oracle DBA , I've always been in the habit of using text files. In fact it's fair to say I'm a command-line warrior. One of the old fashioned school of sysadmins that prefer to do all their work from the Unix cli. This means scripts and data are all stored in text files - in fact most of Unix is run from text files but that is another story. But getting back to those text files. The great beauty of a text file is that no matter what was used to create the text file , be it using vi (or vim ), emacs, MS edit, notepad, wordpad or even write (from windows 3.11 days) your file is readable no matter what machine you take it to. If I create a text file on a Sun Solaris server and copy it over to my little linpus-lite Acer Aspire it can still be read and written to without having to worry about whether I have the right software installed. It's truly portable. Which means I can back it up easily onto a memory stick/pen drive and store a copy on another machine. Another thing is no matter how much information I put in to the text file it's not going to be very large.
I started off using lots of text files for different things. I found this a bit of nuisance when I was trying to keep everything in sync. So I hit upon the idea of using a single large text file for my notes, collected web-links, recipes, tutorials, articles I was trying to write and my own man pages. (man pages for those who don't use Linux or Unix are manual pages giving information on commands, and how to use them - in my case my man pages which are simply sections in my text file give me information on all sorts of things. I shall expand on this later).
I now have a text file whose size is currently around 118Kilobytes in size. And yet it contains my notes I've been collecting about the IBM Z/OS and the Z series platform, notes on NSK Tandem operating system and platforms. It has my man pages, a section for contacts with phone numbers and email addresses. A section for my diary and to do list with appointments. There are sections on tutorials for awk, sed, tcl/tk and Perl programming. I have extracts from Shakespeare's plays (I am trying to learn some of the speeches off by heart). The list goes on.
With just a text editor, the system works well. To make it come alive though you need some extra tools. Tools which are again , small, easy to use and quick to learn (in most cases).
It is probably evident by now though that as Unix sysadmin I am used to some extra tools that Unix and Linux provide which are not available on Windows or DOS (cmd/dos command line). The most important being awk and the next grep. Windows does have a grep of sorts but it's not very powerful but does do what it does well enough. However, it's awk that is the major bonus in Unix. With this simple programming tool I can create databases from simple text files.
Before I started with the large text file system, I developed a sort of wikipedia based on a plain text file with all the entries in it. One that could be expanded easily and quickly. I developed a quick and dirty batch file called pedia.bat which when combined with a small awk program allowed me to type at the command line something like the following (this is an actual extract from my encyclopedia database):
c:>pedia characters
-----------------------------------------------------------
Title:
____ _ _
| _ ___ __| |(_) __ _
| |_) | / _ / _ `|| | / _ `|
| __/ | __/| (_| || || (_| |
|_| ___| __,_||_| __,_|
-----------------------------------------------------------
*
-----------------------------
Search Result
-----------------------------
------------------------------------------------------------ -
Getting rid of unwanted characters in Unix files
If you work in a mixed environment you will often open files
that have ^M's in them. An example would be this:
import java.util.Hashtable; ^M
import java.util.Properties; ^Mimport java.io.IOException;
import org.xml.sax.AttributeList; ^M
import org.xml.sax.HandlerBase; ^Mimport org.xml.sax.SAXException;
/^M
XMLHandler: This class parses the elements contained^M
within a XML message and builds a Hashtable^M
[snip]
Notice that some programs are not consistent in the way they insert
the line breaks so you end up with some lines that have both a carrage
return and a ^M and some lines that have a ^M and no carrage return (
and so blend into one). There are two steps to clean this up.
1. replace all extraneous ^M:
:%s/^M$//g
BE SURE YOU MAKE the ^M USING "CTRL-V CTRL-M" NOT BY TYPING "CARROT M"!
.....
......
As you can see I have a page displayed with some information that I want and nothing else from the encyclopedia. (I'm sorry about the ASCII title - it should read pedia but it's got corrupted and I don't have the inclination or the time to fix it.).
From another section of my text file I can type the following and from the section with my contacts I get the following output:
c:>phone marcus
+===========================+
Telephone Directory
+===========================+
Marcus Handley 07558-881456
Marcus Work Mob 07122-530902
But the magic doesn't stop there. From time to time I have to produce documents that come to a professional or near professional quality typesetting, so simple text is not quite enough. In order to solve this problem I have found a couple of tools that make life even more simpler for use in text files. I came across simple text mark up languages that use simple in-line markup for formatting and allow me to produce rich text format documents and nicely formatted HTML files without having to do any real extra work or HTML coding. I refer to AFT (Almost Free Text) and ReStructured Text. Both of these systems use simple text files and by so marking them , when they are run through a small set of programs they are converted and nicely formatted in either RTF format, HTML, Postscript (.PS) or .pdf format. The in line markup enhances the use of simple text files and doesn't require much in the way of a learning curve.
For instance in ReStructured Text - which I use more frequently, A heading is shown thus
==============
This is a Heading
==============
------------------------------
This is a sub-heading
------------------------------
Introduction
---------------
This shows section headings and the use of **bold text** and *italic text*.
It also demonstrates nicely bullets etc...
1. Text files are
+ portable
+ easy to create, and backup
+ don't take up much space
+ can be formatted as needed
2. Other Advantages include
+ flexibility
(i) displayed as HTML
(ii) displayed as ps output
(iii) RTF (Rich Text Format) output
There is so much more to these systems. They allow me to add images to formatted pages, notes, boxes for information highlighting and so on and yet doesn't make the text look too much different from how I would normally type.
Which produces the following:
This is a Heading
This is a sub-heading
Introduction
This shows section headings and the use of bold text and italic text.
It also demonstrates nicely bullets etc...
- Text files are
- portable
- easy to create, and backup
- don't take up much space
- can be formatted as needed
- Other Advantages include
( i) displayed as HTML
(ii) displayed as ps output
(iii) RTF (Rich Text Format) output
Tomorrow I shall tell you more about the tools I use, where to get them and how to set yourself up to make the most of them. I hope that has whetted your appetites for more. If you have comments or suggestions - polite or otherwise - I would love to hear what you think!
|
|
Posted by ignominius on 2009-07-08 08:07:54 | Rating: | Views: 23
|
|
| |
|
|