format - UDM Command

Syntax

format variable_name [{string_1|expression_1} [align={center|left|right|justify}] [pad=sequence] [trunc=yes|no] [length=length]]...[{string_n|expression_n} [align=center|left|right|justify] [pad=sequence] [trunc=yes|no] [length=length]]

Description

The format command creates a formatted string.

The first parameter, variable_name, is the variable or list element in which the newly formatted string is stored.

The second parameter, string_1 (or expression_1), is the first section of the string. Each additional, optional parameter specifies formatting that affect that string.

All following parameters, string_n (or expression_n), are the next sections of the string. Each additional, optional parameter specifies formatting that affect that string.

Parameters

Parameter

Description

variable_name

Variable or list element in which the newly formatted string is stored

string_1 | expression_1

First section of the string

align=center | left | right | justify

Method of how the value is aligned within the given space.

Default alignment is left.

pad=sequence

Character(s) used to pad out the formatted value.

Default is space character.

trunc=yes | no

Truncates the value to the length given by length if it is longer than that value.

Default is to not truncate.

length=length

Length of the formatted field.

Default is length of the value specified.

Examples


The following examples demonstrate the format command.

set firstname="Stonebranch"
set lastname="Incorporated"
format mystring "First Name: " "$(firstname)"  " Last Name: " +
"$(lastname)" length=3 trunc=yes*
echo "$(mystring)"*

Output:
First Name: Stonebranch Last Name: Inc

format mystring "The " "Value " "Is: " 4 length=8 align=right pad=0*
echo "$(mystring)"
The Value Is: E8E8E804