Brash has many built in functions, mostly they are direct simulations of the basic features available in the unix text processing commands. Use the command, builtins, to get a list of these commands and many of them have --help or -h options to get more details.

Of particular interest are command line options that are added to the normal unix option set and which are designed to make it easier to write scripts:

.ls

The .ls command has a couple of helpful options not in the unix set:

  • --seconds lets you get the time printed as a number of seconds in Jan 1, 197
  • --sep=string lets you specify a character other than space as the field separator
  • -DOS lets you get the old fashioned dos file name format of each file name. The nice thing is that these names do not have spaces or special characters.
  • -Q option puts double quotes around the file name

These optiosn ar meant to make it easieer to use .cut to parse the output of .ls and pick out only the fields that you are interested in -- without having to use complex regular expressions.

.uniq

the .uniq command has several options that change the way it works to make it easier use in practial applications -- basically, since there is not uniq compatible sort command, provided, the .uniq command has options that would normally trigger algorithms that are part of sort. These options include:

  1. The -1 option lets your print 1 copy of every line pattern in the input. This differs from the -u option, in that you get 1 copy of every input line, not just one copy of each unique line.
  2. The -u option lets you get one copy of the unique lines (only)
  3. The -d option lets you get one copy of only the duplicated lines
  4. the -c option lets you get the number of copyies of each pattern.

read

The read command has a couple of helpful options:
-f Causes the reading of an entire file into a single string -- including end of line separators.
-F Causes the reading of an entire file into a array -- one line per row in the array
-a Causes the reading of one line of input and storing it into an array, separated by $IFS characters one word per row

Note that normally read lets you parse a line into words, separated by $IFS characters, one per each variable specified on the read command line.

.regex

The .regex command combines features of grep, sed, and nl. See its options.

.date

The .date command lets you format either the current date or some user specified date into any desired format. See its -h output for details.

.stat

The .stat command exists primarily for script writing. It lets you get the attributes of files into separate variables (or just output lines if you prefer). If you want to look at file attributes, pathnames, etc, see .stat -h.

.cut

This command helps you discard parts of input records that you are not interested in. Basically, it lets you split lines on fields or on character postion. This is all fairly standard in unix terms, though. Still, its very helpful for writing scripts.

See the -w option that lets you switch from splitting on characters to the standard word splitting that is controlled by the $IFS variable.

set

the set command in brash works similar, with regards to parameter splitting to the bourne and bash shells.

Similar to .cut -w.

And yes, set with no parameters will list out all the environment variables.

.exand

Expands tabs into spaces -- or compress spaces into tabs with the -u option.

 

Last edit: Lowell Boggs, Jr. 2018-04-24