


                    [32m  A couple of Hints by Andrew Wong


[32m  <> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <>
[m


[33mEXTRA! AmigaShell Enhances Your Computing Pleasure with Pipes![m

   *** Find the Pipe program mentioned here on the MD_Extras disk this issue.

   Readers familiar with other operating systems such as UNIX and MS-DOS may
  know that the AmigaShell lacks the ability to pipe commands by separating
  them with a vertical bar.  For example, in MS-DOS one can do:

    C> dir | find "string" | sort | more

   which is equivalent to the UNIX command:

    $ ls -l | grep 'string' | sort | more

   but in AmigaDOS this has to be typed:

    1> list to pipe:a
    1> search >pipe:b pipe:a "string" nonum
    1> sort pipe:b pipe:c
    1> more pipe:c

   In fact, AmigaDOS [1mdoes[m have this ability, but it has not been fully
  implemented and exists only as an `undocumented feature'.  It requires the
  presence of the Pipe command, written by Andy Finkel and available on Fish
  673.  This procedure has been tested on AmigaDOS 2.04 and 2.1.

   To discover the joy of pipes for yourself:

    1. Obtain the Pipe program and place it in your search path. Better
       still, make it resident.

            1> resident pipe

    2. Ensure that the PIPE: device is mounted.

            1> mount pipe:

    3. Set the "_pchar" shell variable to a suitable piping character.

            1> set _pchar "|"

    4. For starters, try piping the output of Assign into More.

            1> assign | more

   This method even has an advantage over the piping features offered in
  alternative shells such as WShell and SKsh in that it supplies two fake
  file handles called IN: and OUT: representing, respectively, the data from
  the preceeding command (standard input) and the output to the next command
  (standard output), thus allowing piping to be used with standard Commodore
  commands such as Type and Sort.  For example, the MS-DOS and UNIX commands
  at the start of this article can now be typed as:

    1> list | search in: "string" nonum | sort in: out: | more

   As another example, to obtain a numbered list of directories:

    1> list dirs quick nohead | sort in: out: | type in: number

   Unfortunately, there is a downside: this feature is something of a hack
  and is probably prone to malfunction; in particular, you must be careful
  never to type something like:

    1> command1 | command2 |

  for it will cause the shell to go berserk.  However, the documentation to
  the Pipe command explains how everything above can be accomplished by
  running Pipe explicitly, which is slightly less convenient but more stable
  and is the only method sanctioned by the program's author.


[1mFinding Commands for Pipes[m

   The command-line environment becomes vastly more powerful with the ability
  to pipe commands, but its usefulness depends on the availability of
  commands, known as filters, that can be used in pipelines.

   The SKsh shell contains a great many UNIX commands, many of which can be
  used as filters.  The version of SKsh on Fish 791 includes cat (like Type),
  crc (generates checksums for a file), cut and paste (manipulate lines by
  fields), encr (data encryption), fgrep and grep (like Search), fmt, fold,
  and indent (text formatting), head and tail (display parts of a file), num
  (like Type NUMBER), split (splits a file into pieces), strings (shows the
  printable strings in a file), tee (a pipe double- adapter), wc (counts
  words), xargs (executes a command with arguments from standard input), and
  xd (like Type HEX).

   The AUSH directory on Fish 747 contains a file called ExtraCmds.lha which
  is not mentioned anywhere in the documentation, but which contains versions
  of cut and paste, fold, head and tail, split, strings, tee, and wc similar
  to those that come with SKsh, along with cmp (compares files), comm (shows
  common lines in two files), compute (performs arithmetic on numbers in a
  file), dc (a calculator) newform (text formatting), nl (like SKsh's num),
  and tr (translates characters).

   UnixUtil on Fish 179 contains versions of head and tail, tee, and wc, and
  adds detab and entab (tabs-spaces conversion) and trunc (text formatting).

   ExtraCmds on Fish 774 (not related to the ExtraCmds.lha file mentioned
  above) contains Head, Split, and Tee, along with Common (like comm), Concat
  (like cat), Count (like wc), and Unique (shows repeated lines in a file).
  These commands use AmigaDOS-style syntax and wildcards (eg, "count
  file#? lines words"), unlike those described above, which all use UNIX-like
  syntax (eg, "wc -lw file") and do not support wildcards.

   ARPTools on Fish 284 contains yet more versions of Detab, Entab, Head,
  Tail, String, Tee, Trunc, and Wc, and adds Mr (a simplified version of
  More).  These commands also use AmigaDOS-style syntax and wildcards.

   The old ARP 1.3 distribution contains versions of Search, Sort, and Type
  that can be used in pipes without resorting to the IN: and OUT: devices.

   And finally, for UNIX users: there are ports of GNU egrep, sed, and diff
  on Fish 406, 231, and 821 respectively.  Fish 406 also includes a port of
  GNU awk, and on Fish 821 diff comes with cmp, diff3 (three-way diff), and
  sdiff.



[32m  <> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <>


[33mDisk Validation when Booting[m

   You may have noticed that if, while the Amiga is writing to a disk, you
  accidentally reboot the computer or a program crashes, the operating system
  attempts to validate the disk when the computer starts up again.  If the
  boot volume itself is being validated the startup-sequence will take an
  interminally long time to complete.  It is best to break the
  startup-sequence by pressing CTRL-D, but that is not so easy under
  Kickstart 2.0 because AmigaDOS does not open the initial shell until about
  halfway through the startup-sequence and until then you will have nowhere
  to type CTRL-D to.  The solution is to change the startup- sequence so that
  it will automatically abort if a disk is validating.

   My startup-sequence has the following lines inserted after the line that
  runs SetPatch:

    assign t: ram:
    info >t:user0.t
    search t:user0.t "dh?:#?validating" pattern >nil:
    if not warn
      echo "*nValidating fixed disk(s)."
      echo "Startup-sequence halted.*n"
      quit
    else
      delete t:user0.t quiet
    endif

   The Search command above looks for the string "validating" in the output
  of the Info command, but only in the entries for my hard disks, called
  DH0: and DH1:.  If you change this line to:

    search t:user0.t validating >nil:

  then the startup-sequence will abort if [3many[m disk is validating; if
  you do this it is not a good idea to use the word `validating' when
  labelling any of your disks!



[32m  <> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <%> 34 <>



