Short:        Alternative to strip a given word from a string.
Author:       agneta.nord@swipnet.se (Agneta Nord)
Uploader:     agneta nord swipnet se (Agneta Nord)
Type:         util/cli
Version:      1.0 (7.12.99)
Architecture: m68k-amigaos

Name:

  The name derivates from "Strip A Word".

Purpose:

  I wrote this to simplify scripting while I was dealing with
  logfiles. Usage is within scripts. 'saw' deals with arguments
  only. I can see no relevance in interactive use.

  If You don't do scripts, You probably don't find any use in
  this "utility".

Template:

  saw <word_number> <string>

  'word_number' is a number from 1 and up to 999.

  'string' is the literal string or a variable that contains
  a number of words from which a particular word is searched.

Results:

  The word is output to stdout and can be redirected to a file
  or used to set a variable. A trailing newline is not appended
  intentionally. I didn't want that as it can be used to extract
  a word that is to be joined with other files where a newline
  is not desired. If You need a newline You redirect the output
  to a variable and use ECHO which append a newline character
  for You.

  If You point to a word beyond the list, a word_number that is
  higher than the number of words, 'saw' exits with a warn and
  give no output. See examples below for usage.

  If word_number is not a numeric positive integer You'll have
  a WARNing and not a FAIL.

Examples:

  ---------

  The ENV:vehicles contains "car train boat bike":

    # saw 3 $vehicles >vehicle
    # more vehicle
    boat
    #

  ---------

  The same contents in ENV:vehicles:

    # saw 3 $vehicles
    boat#

  ---------

  Example, fictive logfile excerpt:

    6.12.99 1:15:32 pppd: Local IP 123.234.3.56 recieved

  If You want the IP adress for insertion in an html document,
  in a script You could write something like:

    set ipstring `search <logfile> "Local IP" nonum`
    saw 6 $ipstring >ip  ; from the example above -> 192.168.1.15
    if warn              ; something went wrong
      quit               ; so we bail out
      endif
    join head ip tail to myaddress.html
    unset ipstring

  ---------

  'saw' could also be used to test for a number of words in a string:

    set fruit banana apple orange pineapple pear
    saw 6 $fruit >nil:
    if warn
      echo "There is less than 6 fruits."
      quit
      endif
    echo "There is 6 fruits or more."

  ---------

So what? I use "ECHO START=32 LEN=12 NOLINE".

  Well, in some cases the length of some words are not static
  and tests which could be tedious and error prone would have
  to be performed by the script.