AminetAminet
Search:
84782 packages online
About
Recent
Browse
Search
Upload
Setup
Services

util/cli/saw_1.0.lha

Mirror:Random
Showing: i386-aros icongeneric icon
No screenshot available
Short:Alternative to strip a given word from a string.
Author: agneta.nord at swipnet.se (Agneta Nord)
Uploader:agneta nord swipnet se (Agneta Nord)
Type:util/cli
Version:1.0 (7.12.99)
Architecture:m68k-amigaos
Date:2000-08-16
Download:util/cli/saw_1.0.lha - View contents
Readme:util/cli/saw_1.0.readme
Downloads:439

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.


Contents of util/cli/saw_1.0.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO     CRC       STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[generic]                 4238    6440  65.8% -lh5- c169 Aug 13  2000 saw/saw
[generic]                 1225    2546  48.1% -lh5- 61d4 Aug 13  2000 saw/saw-1.0.readme
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total         2 files    5463    8986  60.8%            Aug 16  2000
Page generated in 0.02 seconds
Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>